driver

package
v0.0.0-...-33ee0dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

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 NewDriver

func NewDriver(mgo mongodb.Mongoer, col bson.M) *Driver

func (*Driver) Aggregate

func (d *Driver) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)

func (*Driver) BulkWrite

func (d *Driver) BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)

func (*Driver) CountDocuments

func (d *Driver) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)

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) Distinct

func (d *Driver) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

func (*Driver) EstimatedDocumentCount

func (d *Driver) EstimatedDocumentCount(ctx context.Context, filter bson.D, opts ...*options.EstimatedDocumentCountOptions) (int64, error)

func (*Driver) FilterByID

func (d *Driver) FilterByID(id primitive.ObjectID) bson.D

func (*Driver) Find

func (d *Driver) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

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) GetMgo

func (d *Driver) GetMgo() (mgo mongodb.Mongoer)

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

func (d *Driver) UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error

如果在DNS处定义了相关concern的options,则无需StartTransaction时设置,否则尽量在StartTransaction时设置相关concern的options 例如:

err := sctx.StartTransaction(options.Transaction().SetReadConcern(readconcern.Majority()).SetWriteConcern(writeconcern.New(writeconcern.WMajority())))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL