Documentation ¶
Index ¶
- type Driver
- func (d *Driver) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
- func (d *Driver) BulkWrite(ctx context.Context, models []mongo.WriteModel, ...) (*mongo.BulkWriteResult, error)
- func (d *Driver) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (d *Driver) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (d *Driver) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (d *Driver) Distinct(ctx context.Context, fieldName string, filter interface{}, ...) ([]interface{}, error)
- func (d *Driver) EstimatedDocumentCount(ctx context.Context, filter bson.D, ...) (int64, error)
- func (d *Driver) FilterByID(id primitive.ObjectID) bson.D
- func (d *Driver) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (d *Driver) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (d *Driver) FindOneAndDelete(ctx context.Context, filter interface{}, ...) *mongo.SingleResult
- func (d *Driver) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, ...) *mongo.SingleResult
- func (d *Driver) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, ...) *mongo.SingleResult
- func (d *Driver) GetMgo() (mgo mongodb.Mongoer)
- func (d *Driver) InsertMany(ctx context.Context, documents []interface{}, ...) (*mongo.InsertManyResult, error)
- func (d *Driver) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (d *Driver) ProjectionOne(bd bson.D) *options.FindOneOptions
- func (d *Driver) ProjectionOneID() *options.FindOneOptions
- func (d *Driver) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, ...) (*mongo.UpdateResult, error)
- func (d *Driver) UpdateByID(ctx context.Context, id interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (d *Driver) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (d *Driver) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (d *Driver) UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func (*Driver) BulkWrite ¶
func (d *Driver) BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
func (*Driver) CountDocuments ¶
func (*Driver) DeleteMany ¶
func (d *Driver) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Driver) DeleteOne ¶
func (d *Driver) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Driver) EstimatedDocumentCount ¶
func (*Driver) FindOne ¶
func (d *Driver) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
func (*Driver) FindOneAndDelete ¶
func (d *Driver) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
func (*Driver) FindOneAndReplace ¶
func (d *Driver) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult
func (*Driver) FindOneAndUpdate ¶
func (d *Driver) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult
func (*Driver) InsertMany ¶
func (d *Driver) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
func (*Driver) InsertOne ¶
func (d *Driver) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*Driver) ProjectionOne ¶
func (d *Driver) ProjectionOne(bd bson.D) *options.FindOneOptions
func (*Driver) ProjectionOneID ¶
func (d *Driver) ProjectionOneID() *options.FindOneOptions
func (*Driver) ReplaceOne ¶
func (d *Driver) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
func (*Driver) UpdateByID ¶
func (d *Driver) UpdateByID(ctx context.Context, id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Driver) UpdateMany ¶
func (d *Driver) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Driver) UpdateOne ¶
func (d *Driver) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Driver) UseSession ¶
如果在DNS处定义了相关concern的options,则无需StartTransaction时设置,否则尽量在StartTransaction时设置相关concern的options 例如:
err := sctx.StartTransaction(options.Transaction().SetReadConcern(readconcern.Majority()).SetWriteConcern(writeconcern.New(writeconcern.WMajority())))
Click to show internal directories.
Click to hide internal directories.