Documentation
¶
Index ¶
- func WithTransaction(callback func(sessCtx mongo.SessionContext) (interface{}, error), ...) (interface{}, error)
- type DatabaseBase
- type FindOption
- type InsertOneResult
- type MongoDBConfig
- type MongoDb
- func (db *MongoDb) Aggregate(ctx context.Context, collection string, pipeline interface{}, docs interface{}) error
- func (db *MongoDb) AggregateOne(ctx context.Context, collection string, pipeline interface{}, doc interface{}) error
- func (db *MongoDb) Close()
- func (db *MongoDb) Connect()
- func (db *MongoDb) Count(ctx context.Context, collection string, filter interface{}) (int64, error)
- func (db *MongoDb) DeleteMany(ctx context.Context, collection string, filter interface{}) (interface{}, error)
- func (db *MongoDb) DeleteOne(ctx context.Context, collection string, filter interface{}) (interface{}, error)
- func (db *MongoDb) Distinct(ctx context.Context, collection, fieldName string, filter interface{}) ([]string, error)
- func (db *MongoDb) EnsureIndex(ctx context.Context, collection string, name string, keys bson.M, unique bool) string
- func (db *MongoDb) Find(ctx context.Context, collection string, filter interface{}, option FindOption, ...) error
- func (db *MongoDb) FindOne(ctx context.Context, collection string, filter interface{}, ...) error
- func (db *MongoDb) FindOneAndUpdate(ctx context.Context, collection string, filter interface{}, ...) error
- func (db *MongoDb) GetClient() interface{}
- func (db *MongoDb) GetCollection(collection string) interface{}
- func (db *MongoDb) GetCursor(ctx context.Context, collection string, filter, sort interface{}, ...) (interface{}, error)
- func (db *MongoDb) Init(i interface{}) error
- func (db *MongoDb) Insert(ctx context.Context, collection string, doc interface{}) (InsertOneResult, error)
- func (db *MongoDb) InsertMany(ctx context.Context, collection string, docs []interface{}) ([]interface{}, error)
- func (db *MongoDb) UpdateMany(ctx context.Context, collection string, filter interface{}, update interface{}) (interface{}, error)
- func (db *MongoDb) UpdateOne(ctx context.Context, collection string, filter interface{}, update interface{}) (UpdateOneResult, error)
- type Order
- type UpdateOneResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTransaction ¶
func WithTransaction(callback func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*options.TransactionOptions) (interface{}, error)
Types ¶
type DatabaseBase ¶
type DatabaseBase interface { Init(config interface{}) error Connect() Close() GetClient() interface{} GetCollection(collection string) interface{} GetCursor(ctx context.Context, collection string, filter, sort interface{}, skip, limit int64, projection interface{}) (interface{}, error) Find(ctx context.Context, collection string, filter interface{}, option FindOption, projection, docs interface{}) error Distinct(ctx context.Context, collection, fieldName string, filter interface{}) ([]string, error) Aggregate(ctx context.Context, collection string, pipeline interface{}, docs interface{}) error FindOne(ctx context.Context, collection string, filter interface{}, projection interface{}, doc interface{}) error AggregateOne(ctx context.Context, collection string, pipeline interface{}, doc interface{}) error // Insert executes an insert command to insert a single document into the collection. // The _id can be retrieved from the result. Insert(ctx context.Context, collection string, doc interface{}) (InsertOneResult, error) InsertMany(ctx context.Context, collection string, docs []interface{}) ([]interface{}, error) UpdateOne(ctx context.Context, collection string, filter, doc interface{}) (UpdateOneResult, error) FindOneAndUpdate(ctx context.Context, collection string, filter, update, doc interface{}) error UpdateMany(ctx context.Context, collection string, filter interface{}, doc interface{}) (interface{}, error) DeleteOne(ctx context.Context, collection string, filter interface{}) (interface{}, error) DeleteMany(ctx context.Context, collection string, filter interface{}) (interface{}, error) Count(ctx context.Context, collection string, filter interface{}) (int64, error) EnsureIndex(ctx context.Context, collection string, name string, keys bson.M, unique bool) string }
type InsertOneResult ¶
type InsertOneResult struct {
Id interface{} `json:"id"`
}
type MongoDBConfig ¶
type MongoDBConfig struct { Host string `yaml:"host"` Username string `yaml:"user"` Password string `yaml:"password"` AuthSource string `yaml:"authSource"` Name string `yaml:"name"` ReplicaSet string `yaml:"replicaSet"` }
YAML config for MongoDB
func (*MongoDBConfig) IsValid ¶
func (c *MongoDBConfig) IsValid() bool
type MongoDb ¶
type MongoDb struct { DatabaseBase // contains filtered or unexported fields }
func GetMongoDb ¶
func GetMongoDb() *MongoDb
func (*MongoDb) AggregateOne ¶
func (*MongoDb) DeleteMany ¶
func (*MongoDb) EnsureIndex ¶
func (*MongoDb) FindOneAndUpdate ¶
func (*MongoDb) GetClient ¶
func (db *MongoDb) GetClient() interface{}
Returns the current session, *mongo.Client
func (*MongoDb) GetCollection ¶ added in v0.2.10
func (*MongoDb) InsertMany ¶
func (*MongoDb) UpdateMany ¶
type UpdateOneResult ¶
type UpdateOneResult struct {
Id interface{} `json:"id"`
}
Click to show internal directories.
Click to hide internal directories.