Versions in this module Expand all Collapse all v1 v1.1.9 Jun 19, 2024 Changes in this version + var ErrNoSuchDocuments = mongo.ErrNoDocuments + var ErrNotSupportedPassword = errors.New("password not supported") + var ErrNotSupportedUsername = errors.New("username not supported") + var ErrNotValidSliceToInsert = errors.New("must be valid slice to insert") + var ErrQueryNotSlicePointer = errors.New("result argument must be a pointer to a slice") + var ErrQueryNotSliceType = errors.New("result argument must be a slice address") + var ErrQueryResultTypeInconsistent = errors.New("result type is not equal mongodb value type") + var ErrQueryResultValCanNotChange = errors.New("the value of result can not be changed") + var ErrReplacementContainUpdateOperators = errors.New("replacement document cannot contain keys beginning with '$'") + var ErrTransactionNotSupported = errors.New("transaction not supported") + var ErrTransactionRetry = errors.New("retry transaction") + func CompareVersions(v1 string, v2 string) (int, error) + func IsDup(err error) bool + func IsErrNoDocuments(err error) bool + func NewObjectID() primitive.ObjectID + func Now() time.Time + func SplitSortField(field string) (key string, sort int32) + type A = bson.A + type Aggregate struct + func (a *Aggregate) All(results interface{}) error + func (a *Aggregate) Cursor() CursorI + func (a *Aggregate) Iter() CursorI + func (a *Aggregate) One(result interface{}) error + type AggregateI interface + All func(results interface{}) error + Cursor func() CursorI + Iter func() CursorI + One func(result interface{}) error + type Bulk struct + func (b *Bulk) InsertOne(doc interface{}) *Bulk + func (b *Bulk) Remove(filter interface{}) *Bulk + func (b *Bulk) RemoveAll(filter interface{}) *Bulk + func (b *Bulk) RemoveId(id interface{}) *Bulk + func (b *Bulk) Run(ctx context.Context) (*BulkResult, error) + func (b *Bulk) SetOrdered(ordered bool) *Bulk + func (b *Bulk) UpdateAll(filter interface{}, update interface{}) *Bulk + func (b *Bulk) UpdateId(id interface{}, update interface{}) *Bulk + func (b *Bulk) UpdateOne(filter interface{}, update interface{}) *Bulk + func (b *Bulk) Upsert(filter interface{}, replacement interface{}) *Bulk + func (b *Bulk) UpsertId(id interface{}, replacement interface{}) *Bulk + func (b *Bulk) UpsertOne(filter interface{}, update interface{}) *Bulk + type BulkResult struct + DeletedCount int64 + InsertedCount int64 + MatchedCount int64 + ModifiedCount int64 + UpsertedCount int64 + UpsertedIDs map[int64]interface{} + type Change struct + Remove bool + Replace bool + ReturnNew bool + Update interface{} + Upsert bool + type Client struct + func NewClient(ctx context.Context, conf *Config, o ...options.ClientOptions) (cli *Client, err error) + func (c *Client) Close(ctx context.Context) error + func (c *Client) Database(name string, options ...*options.DatabaseOptions) *Database + func (c *Client) DoTransaction(ctx context.Context, ...) (interface{}, error) + func (c *Client) Ping(timeout int64) error + func (c *Client) ServerVersion() string + func (c *Client) Session(opt ...*options.SessionOptions) (*Session, error) + type Collection struct + func (c *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...opts.AggregateOptions) AggregateI + func (c *Collection) Bulk() *Bulk + func (c *Collection) CloneCollection() (*mongo.Collection, error) + func (c *Collection) CreateIndexes(ctx context.Context, indexes []opts.IndexModel) (err error) + func (c *Collection) CreateOneIndex(ctx context.Context, index opts.IndexModel) error + func (c *Collection) DropAllIndexes(ctx context.Context) (err error) + func (c *Collection) DropCollection(ctx context.Context) error + func (c *Collection) DropIndex(ctx context.Context, indexes []string) error + func (c *Collection) EnsureIndexes(ctx context.Context, uniques []string, indexes []string) (err error) + func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...opts.FindOptions) QueryI + func (c *Collection) GetCollectionName() string + func (c *Collection) InsertMany(ctx context.Context, docs interface{}, opts ...opts.InsertManyOptions) (result *InsertManyResult, err error) + func (c *Collection) InsertOne(ctx context.Context, doc interface{}, opts ...opts.InsertOneOptions) (result *InsertOneResult, err error) + func (c *Collection) Remove(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (err error) + func (c *Collection) RemoveAll(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (result *DeleteResult, err error) + func (c *Collection) RemoveId(ctx context.Context, id interface{}, opts ...opts.RemoveOptions) (err error) + func (c *Collection) ReplaceOne(ctx context.Context, filter interface{}, doc interface{}, ...) (err error) + func (c *Collection) UpdateAll(ctx context.Context, filter interface{}, update interface{}, ...) (result *UpdateResult, err error) + func (c *Collection) UpdateId(ctx context.Context, id interface{}, update interface{}, ...) (err error) + func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (err error) + func (c *Collection) Upsert(ctx context.Context, filter interface{}, replacement interface{}, ...) (result *UpdateResult, err error) + func (c *Collection) UpsertId(ctx context.Context, id interface{}, replacement interface{}, ...) (result *UpdateResult, err error) + func (c *Collection) Watch(ctx context.Context, pipeline interface{}, opts ...*opts.ChangeStreamOptions) (*mongo.ChangeStream, error) + type Config struct + Auth *Credential + Coll string + ConnectTimeoutMS *int64 + Database string + MaxPoolSize *uint64 + MinPoolSize *uint64 + ReadPreference *ReadPref + SocketTimeoutMS *int64 + Uri string + type Credential struct + AuthMechanism string + AuthSource string + Password string + PasswordSet bool + Username string + type Cursor struct + func (c *Cursor) All(results interface{}) error + func (c *Cursor) Close() error + func (c *Cursor) Err() error + func (c *Cursor) Next(result interface{}) bool + type CursorI interface + All func(results interface{}) error + Close func() error + Err func() error + Next func(result interface{}) bool + type D = bson.D + type Database struct + func (d *Database) Collection(name string, opts ...*options.CollectionOptions) *Collection + func (d *Database) DropDatabase(ctx context.Context) error + func (d *Database) GetDatabaseName() string + func (d *Database) RunCommand(ctx context.Context, runCommand interface{}, opts ...options.RunCommandOptions) *mongo.SingleResult + func (db *Database) CreateCollection(ctx context.Context, name string, opts ...options.CreateCollectionOptions) error + type DeleteResult struct + DeletedCount int64 + type E = bson.E + type InsertManyResult struct + InsertedIDs []interface{} + type InsertOneResult struct + InsertedID interface{} + type M = bson.M + type Pipeline []bson.D + type QmgoClient struct + func Open(ctx context.Context, conf *Config, o ...options.ClientOptions) (cli *QmgoClient, err error) + type Query struct + func (q *Query) All(result interface{}) error + func (q *Query) Apply(change Change, result interface{}) error + func (q *Query) BatchSize(n int64) QueryI + func (q *Query) Collation(collation *options.Collation) QueryI + func (q *Query) Count() (n int64, err error) + func (q *Query) Cursor() CursorI + func (q *Query) Distinct(key string, result interface{}) error + func (q *Query) EstimatedCount() (n int64, err error) + func (q *Query) Hint(hint interface{}) QueryI + func (q *Query) Limit(n int64) QueryI + func (q *Query) NoCursorTimeout(n bool) QueryI + func (q *Query) One(result interface{}) error + func (q *Query) Select(projection interface{}) QueryI + func (q *Query) SetArrayFilters(filter *options.ArrayFilters) QueryI + func (q *Query) Skip(n int64) QueryI + func (q *Query) Sort(fields ...string) QueryI + type QueryI interface + All func(result interface{}) error + Apply func(change Change, result interface{}) error + BatchSize func(n int64) QueryI + Collation func(collation *options.Collation) QueryI + Count func() (n int64, err error) + Cursor func() CursorI + Distinct func(key string, result interface{}) error + EstimatedCount func() (n int64, err error) + Hint func(hint interface{}) QueryI + Limit func(n int64) QueryI + NoCursorTimeout func(n bool) QueryI + One func(result interface{}) error + Select func(selector interface{}) QueryI + SetArrayFilters func(*options.ArrayFilters) QueryI + Skip func(n int64) QueryI + Sort func(fields ...string) QueryI + type ReadPref struct + MaxStalenessMS int64 + Mode readpref.Mode + type Session struct + func (s *Session) AbortTransaction(ctx context.Context) error + func (s *Session) EndSession(ctx context.Context) + func (s *Session) StartTransaction(ctx context.Context, cb func(sessCtx context.Context) (interface{}, error), ...) (interface{}, error) + type UpdateResult struct + MatchedCount int64 + ModifiedCount int64 + UpsertedCount int64 + UpsertedID interface{}