Documentation
¶
Index ¶
- Constants
- func AddMongoBeforeSaveObserver(f MongoBeforeSaveFunc)
- func GetAllMongoDBs() map[string]*MongoSession
- func GetCollectionName(dst interface{}) string
- func GetMetaField(model interface{}) (reflect.StructField, bool)
- func GetModelPk(model interface{}) reflect.Value
- func InitMongoDB(dbConfigs map[string]definations.DBConnectorConfig) error
- func MongoOrganizeUpdatesFields(v interface{}) interface{}
- type ErrorMongoDB
- type MongoBeforeSaveFunc
- type MongoCollectionIndex
- type MongoMeta
- type MongoSession
- func (s *MongoSession) DeleteOne(dst interface{}, isInsert bool) error
- func (s *MongoSession) FindAll(collectionName string, filter bson.D) ([]bson.M, error)
- func (s *MongoSession) FindOne(dst interface{}, filter interface{}, opts ...*options.FindOneOptions) error
- func (s *MongoSession) GetCollection(collectionName string) *mongo.Collection
- func (s *MongoSession) IsMongoDBReady() bool
- func (s *MongoSession) MongoDBInsertMany(collectionName string, docs []interface{}) bool
- func (s *MongoSession) Ping() error
- func (s *MongoSession) QueryFind(model interface{}, filter interface{}, limit int64, results interface{}) (int, error)
- func (s *MongoSession) QueryMaxID(model interface{}, result interface{}, aggField string) error
- func (s *MongoSession) SaveOne(dst interface{}, isInsert bool) error
- func (s *MongoSession) StartKeepAlive()
Constants ¶
const ( // MongoDBPingInterval mongodb heatbeat ping interval MongoDBPingInterval = 5 MongoDBConnectTimeout = 15 MongoDBPingTimeout = 8 MongoDBQueryTimeout = 30 MongoDBDriverName = "mongodb" )
Constant
Variables ¶
This section is empty.
Functions ¶
func AddMongoBeforeSaveObserver ¶
func AddMongoBeforeSaveObserver(f MongoBeforeSaveFunc)
AddMongoBeforeSaveObserver observer
func GetAllMongoDBs ¶ added in v0.2.2
func GetAllMongoDBs() map[string]*MongoSession
GetAllMongoDBs all iterable mongo sessions
func GetCollectionName ¶
func GetCollectionName(dst interface{}) string
GetCollectionName get collection name by model
func GetMetaField ¶
func GetMetaField(model interface{}) (reflect.StructField, bool)
GetMetaField get meta field by model
func InitMongoDB ¶
func InitMongoDB(dbConfigs map[string]definations.DBConnectorConfig) error
InitMongoDB initialzie mongodb sessions
func MongoOrganizeUpdatesFields ¶ added in v0.2.2
func MongoOrganizeUpdatesFields(v interface{}) interface{}
MongoOrganizeUpdatesFields make {"$set": { }} fields
Types ¶
type ErrorMongoDB ¶
type ErrorMongoDB string
ErrorMongoDB mongodb error
func (ErrorMongoDB) Error ¶
func (s ErrorMongoDB) Error() string
Error error message for mongodb error
type MongoBeforeSaveFunc ¶
type MongoBeforeSaveFunc func(v interface{})
MongoBeforeSaveFunc mongodb before save event callback
type MongoCollectionIndex ¶
MongoCollectionIndex struct
func PrepareCollectionIndexes ¶
func PrepareCollectionIndexes(dst interface{}) []MongoCollectionIndex
PrepareCollectionIndexes prepare indexes
type MongoMeta ¶
type MongoMeta struct {
// contains filtered or unexported fields
}
MongoMeta mongodb models meta structure
type MongoSession ¶
type MongoSession struct { Client *mongo.Client Database string LastError error Name string // contains filtered or unexported fields }
MongoSession mongodb session
func (*MongoSession) DeleteOne ¶
func (s *MongoSession) DeleteOne(dst interface{}, isInsert bool) error
DeleteOne delete
func (*MongoSession) FindOne ¶
func (s *MongoSession) FindOne(dst interface{}, filter interface{}, opts ...*options.FindOneOptions) error
FindOne finder
func (*MongoSession) GetCollection ¶
func (s *MongoSession) GetCollection(collectionName string) *mongo.Collection
GetCollection get mongodb collection
func (*MongoSession) IsMongoDBReady ¶
func (s *MongoSession) IsMongoDBReady() bool
IsMongoDBReady is ready
func (*MongoSession) MongoDBInsertMany ¶
func (s *MongoSession) MongoDBInsertMany(collectionName string, docs []interface{}) bool
MongoDBInsertMany insert many
func (*MongoSession) QueryFind ¶
func (s *MongoSession) QueryFind(model interface{}, filter interface{}, limit int64, results interface{}) (int, error)
QueryFind query
func (*MongoSession) QueryMaxID ¶
func (s *MongoSession) QueryMaxID(model interface{}, result interface{}, aggField string) error
QueryMaxID query max id
func (*MongoSession) SaveOne ¶
func (s *MongoSession) SaveOne(dst interface{}, isInsert bool) error
SaveOne save
func (*MongoSession) StartKeepAlive ¶
func (s *MongoSession) StartKeepAlive()
StartKeepAlive keepalive