Documentation ¶
Index ¶
- func CollectionExists(db *mongo.Database, coll string) (bool, error)
- func CollectionsMatchTimePattern(db *mongo.Database, pattern string) ([]string, error)
- func CountDocuments(client *mongo.Client, dsn, coll string) (int64, error)
- func CreateIndex(coll *mongo.Collection, indexes map[string]int) error
- func CreateIndexIfNotExists(db *mongo.Database, collname string, indexes map[string]int) error
- func ListCollections(client *mongo.Client, dsn string) ([]string, error)
- func ParseDsn(dsn string) (connstring.ConnString, error)
- func TakeMongoClient(dsn string) (*mongo.Client, error)
- func ToClickhouseTable(dsn, db, tablename, indexes string, withTime bool) ([]string, string, error)
- type MongoModel
- func (m *MongoModel) All() (interface{}, error)
- func (m *MongoModel) BatchInsert(vs interface{}) error
- func (m *MongoModel) DeleteWhere(where bson.M) (int64, error)
- func (m *MongoModel) Drop() error
- func (m *MongoModel) Insert(v interface{}) error
- func (m *MongoModel) MustAll() interface{}
- func (m *MongoModel) QueryWhere(where bson.M) (interface{}, error)
- func (m *MongoModel) UpdateSets(where, sets bson.M) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectionExists ¶
CollectionExists check if collection exists
func CreateIndex ¶
func CreateIndex(coll *mongo.Collection, indexes map[string]int) error
CreateIndex creates indexes for coll
func CreateIndexIfNotExists ¶
CreateIndexIfNotExists create indexes if collection doesn't exists
func ParseDsn ¶
func ParseDsn(dsn string) (connstring.ConnString, error)
Types ¶
type MongoModel ¶
type MongoModel struct { Client *mongo.Client AppName string Dsn string Database string Collection string Type reflect.Type Indexes map[string]int FieldBsons []string }
func MustNewMongoModel ¶
func MustNewMongoModel(appName, dsn string, data interface{}) (*MongoModel, error)
func NewMongoModel ¶
func NewMongoModel(appName, dsn string, data interface{}) (*MongoModel, error)
func (*MongoModel) All ¶
func (m *MongoModel) All() (interface{}, error)
func (*MongoModel) BatchInsert ¶
func (m *MongoModel) BatchInsert(vs interface{}) error
func (*MongoModel) DeleteWhere ¶
func (m *MongoModel) DeleteWhere(where bson.M) (int64, error)
func (*MongoModel) Insert ¶
func (m *MongoModel) Insert(v interface{}) error
func (*MongoModel) MustAll ¶
func (m *MongoModel) MustAll() interface{}
func (*MongoModel) QueryWhere ¶
func (m *MongoModel) QueryWhere(where bson.M) (interface{}, error)
func (*MongoModel) UpdateSets ¶
func (m *MongoModel) UpdateSets(where, sets bson.M) (int64, error)
Click to show internal directories.
Click to hide internal directories.