Versions in this module Expand all Collapse all v1 v1.1.0 May 26, 2022 v1.0.0 May 26, 2022 Changes in this version + var ErrClientDisconnected = errors.New("client is disconnected") + var ErrEmptySlice = errors.New("must provide at least one element in input slice") + var ErrInvalidIndexValue = errors.New("invalid index value") + var ErrMissingResumeToken = errors.New("cannot provide resume functionality when the resume token is missing") + var ErrMultipleIndexDrop = errors.New("multiple indexes would be dropped") + var ErrNilCursor = errors.New("cursor is nil") + var ErrNilDocument = errors.New("document is nil") + var ErrNoDocuments = errors.New("mongo: no documents in result") + var ErrNonStringIndexName = errors.New("index name must be a string") + var ErrUnacknowledgedWrite = errors.New("unacknowledged write") + var ErrWrongClient = errors.New("session was not created by this client") + func BatchCursorFromCursor(c *Cursor) *driver.BatchCursor + func CmdbGetSessionInfo(sess Session) (string, int64, error) + func CmdbPrepareCommitOrAbort(sess Session) + func CmdbReleaseSession(ctx context.Context, sess Session) + func CmdbReloadSession(sess Session, info *SessionInfo) error + func WithSession(ctx context.Context, sess Session, fn func(SessionContext) error) error + type BSONAppender interface + AppendBSON func([]byte, interface{}) ([]byte, error) + type BSONAppenderFunc func([]byte, interface{}) ([]byte, error) + func (baf BSONAppenderFunc) AppendBSON(dst []byte, val interface{}) ([]byte, error) + type BulkWriteError struct + Request WriteModel + func (bwe BulkWriteError) Error() string + type BulkWriteException struct + WriteConcernError *WriteConcernError + WriteErrors []BulkWriteError + func (bwe BulkWriteException) Error() string + type BulkWriteResult struct + DeletedCount int64 + InsertedCount int64 + MatchedCount int64 + ModifiedCount int64 + UpsertedCount int64 + UpsertedIDs map[int64]interface{} + type ChangeStream struct + Current bson.Raw + func (cs *ChangeStream) Close(ctx context.Context) error + func (cs *ChangeStream) Decode(val interface{}) error + func (cs *ChangeStream) Err() error + func (cs *ChangeStream) ID() int64 + func (cs *ChangeStream) Next(ctx context.Context) bool + func (cs *ChangeStream) ResumeToken() bson.Raw + type Client struct + func Connect(ctx context.Context, opts ...*options.ClientOptions) (*Client, error) + func NewClient(opts ...*options.ClientOptions) (*Client, error) + func (c *Client) Connect(ctx context.Context) error + func (c *Client) Database(name string, opts ...*options.DatabaseOptions) *Database + func (c *Client) Disconnect(ctx context.Context) error + func (c *Client) ListDatabaseNames(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) ([]string, error) + func (c *Client) ListDatabases(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) (ListDatabasesResult, error) + func (c *Client) Ping(ctx context.Context, rp *readpref.ReadPref) error + func (c *Client) StartSession(opts ...*options.SessionOptions) (Session, error) + func (c *Client) UseSession(ctx context.Context, fn func(SessionContext) error) error + func (c *Client) UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, ...) error + func (c *Client) Watch(ctx context.Context, pipeline interface{}, ...) (*ChangeStream, error) + type Collection struct + func (coll *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*Cursor, error) + func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel, opts ...*options.BulkWriteOptions) (*BulkWriteResult, error) + func (coll *Collection) Clone(opts ...*options.CollectionOptions) (*Collection, error) + func (coll *Collection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error) + func (coll *Collection) Database() *Database + func (coll *Collection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*DeleteResult, error) + func (coll *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*DeleteResult, error) + func (coll *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, ...) ([]interface{}, error) + func (coll *Collection) Drop(ctx context.Context) error + func (coll *Collection) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error) + func (coll *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*Cursor, error) + func (coll *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *SingleResult + func (coll *Collection) FindOneAndDelete(ctx context.Context, filter interface{}, ...) *SingleResult + func (coll *Collection) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, ...) *SingleResult + func (coll *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, ...) *SingleResult + func (coll *Collection) Indexes() IndexView + func (coll *Collection) InsertMany(ctx context.Context, documents []interface{}, ...) (*InsertManyResult, error) + func (coll *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*InsertOneResult, error) + func (coll *Collection) Name() string + func (coll *Collection) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, ...) (*UpdateResult, error) + func (coll *Collection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*UpdateResult, error) + func (coll *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*UpdateResult, error) + func (coll *Collection) Watch(ctx context.Context, pipeline interface{}, ...) (*ChangeStream, error) + type CommandError struct + Code int32 + Labels []string + Message string + Name string + func (e CommandError) Error() string + func (e CommandError) HasErrorLabel(label string) bool + func (e CommandError) IsMaxTimeMSExpiredError() bool + type Cursor struct + Current bson.Raw + func (c *Cursor) All(ctx context.Context, results interface{}) error + func (c *Cursor) Close(ctx context.Context) error + func (c *Cursor) Decode(val interface{}) error + func (c *Cursor) Err() error + func (c *Cursor) ID() int64 + func (c *Cursor) Next(ctx context.Context) bool + type Database struct + func (db *Database) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*Cursor, error) + func (db *Database) Client() *Client + func (db *Database) Collection(name string, opts ...*options.CollectionOptions) *Collection + func (db *Database) Drop(ctx context.Context) error + func (db *Database) ListCollectionNames(ctx context.Context, filter interface{}, ...) ([]string, error) + func (db *Database) ListCollections(ctx context.Context, filter interface{}, ...) (*Cursor, error) + func (db *Database) Name() string + func (db *Database) ReadConcern() *readconcern.ReadConcern + func (db *Database) ReadPreference() *readpref.ReadPref + func (db *Database) RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) *SingleResult + func (db *Database) RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (*Cursor, error) + func (db *Database) Watch(ctx context.Context, pipeline interface{}, ...) (*ChangeStream, error) + func (db *Database) WriteConcern() *writeconcern.WriteConcern + type DatabaseSpecification struct + Empty bool + Name string + SizeOnDisk int64 + type DeleteManyModel struct + Collation *options.Collation + Filter interface{} + func NewDeleteManyModel() *DeleteManyModel + func (dmm *DeleteManyModel) SetCollation(collation *options.Collation) *DeleteManyModel + func (dmm *DeleteManyModel) SetFilter(filter interface{}) *DeleteManyModel + type DeleteOneModel struct + Collation *options.Collation + Filter interface{} + func NewDeleteOneModel() *DeleteOneModel + func (dom *DeleteOneModel) SetCollation(collation *options.Collation) *DeleteOneModel + func (dom *DeleteOneModel) SetFilter(filter interface{}) *DeleteOneModel + type DeleteResult struct + DeletedCount int64 + type Dialer interface + DialContext func(ctx context.Context, network, address string) (net.Conn, error) + type IndexModel struct + Keys interface{} + Options *options.IndexOptions + type IndexOptionsBuilder struct + func NewIndexOptionsBuilder() *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Background(background bool) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Bits(bits int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) BucketSize(bucketSize int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Build() bson.D + func (iob *IndexOptionsBuilder) Collation(collation interface{}) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) DefaultLanguage(defaultLanguage string) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) ExpireAfterSeconds(expireAfterSeconds int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) LanguageOverride(languageOverride string) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Max(max float64) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Min(min float64) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Name(name string) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) PartialFilterExpression(partialFilterExpression interface{}) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Sparse(sparse bool) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) SphereVersion(sphereVersion int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) StorageEngine(storageEngine interface{}) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) TextVersion(textVersion int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Unique(unique bool) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Version(version int32) *IndexOptionsBuilder + func (iob *IndexOptionsBuilder) Weights(weights interface{}) *IndexOptionsBuilder + type IndexView struct + func (iv IndexView) CreateMany(ctx context.Context, models []IndexModel, ...) ([]string, error) + func (iv IndexView) CreateOne(ctx context.Context, model IndexModel, opts ...*options.CreateIndexesOptions) (string, error) + func (iv IndexView) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error) + func (iv IndexView) DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error) + func (iv IndexView) List(ctx context.Context, opts ...*options.ListIndexesOptions) (*Cursor, error) + type InsertManyResult struct + InsertedIDs []interface{} + type InsertOneModel struct + Document interface{} + func NewInsertOneModel() *InsertOneModel + func (iom *InsertOneModel) SetDocument(doc interface{}) *InsertOneModel + type InsertOneResult struct + InsertedID interface{} + type ListDatabasesResult struct + Databases []DatabaseSpecification + TotalSize int64 + type MarshalError struct + Err error + Value interface{} + func (me MarshalError) Error() string + type Pipeline []bson.D + type ReplaceOneModel struct + Collation *options.Collation + Filter interface{} + Replacement interface{} + Upsert *bool + func NewReplaceOneModel() *ReplaceOneModel + func (rom *ReplaceOneModel) SetCollation(collation *options.Collation) *ReplaceOneModel + func (rom *ReplaceOneModel) SetFilter(filter interface{}) *ReplaceOneModel + func (rom *ReplaceOneModel) SetReplacement(rep interface{}) *ReplaceOneModel + func (rom *ReplaceOneModel) SetUpsert(upsert bool) *ReplaceOneModel + type Session interface + AbortTransaction func(context.Context) error + AdvanceClusterTime func(bson.Raw) error + AdvanceOperationTime func(*primitive.Timestamp) error + Client func() *Client + ClusterTime func() bson.Raw + CommitTransaction func(context.Context) error + EndSession func(context.Context) + OperationTime func() *primitive.Timestamp + StartTransaction func(...*options.TransactionOptions) error + WithTransaction func(ctx context.Context, fn func(sessCtx SessionContext) (interface{}, error), ...) (interface{}, error) + type SessionContext interface + func CmdbContextWithSession(ctx context.Context, sess Session) SessionContext + type SessionInfo struct + SessionID string + TxnNubmer int64 + type SingleResult struct + func (sr *SingleResult) Decode(v interface{}) error + func (sr *SingleResult) DecodeBytes() (bson.Raw, error) + func (sr *SingleResult) Err() error + type StreamType uint8 + const ClientStream + const CollectionStream + const DatabaseStream + type UpdateManyModel struct + ArrayFilters *options.ArrayFilters + Collation *options.Collation + Filter interface{} + Update interface{} + Upsert *bool + func NewUpdateManyModel() *UpdateManyModel + func (umm *UpdateManyModel) SetArrayFilters(filters options.ArrayFilters) *UpdateManyModel + func (umm *UpdateManyModel) SetCollation(collation *options.Collation) *UpdateManyModel + func (umm *UpdateManyModel) SetFilter(filter interface{}) *UpdateManyModel + func (umm *UpdateManyModel) SetUpdate(update interface{}) *UpdateManyModel + func (umm *UpdateManyModel) SetUpsert(upsert bool) *UpdateManyModel + type UpdateOneModel struct + ArrayFilters *options.ArrayFilters + Collation *options.Collation + Filter interface{} + Update interface{} + Upsert *bool + func NewUpdateOneModel() *UpdateOneModel + func (uom *UpdateOneModel) SetArrayFilters(filters options.ArrayFilters) *UpdateOneModel + func (uom *UpdateOneModel) SetCollation(collation *options.Collation) *UpdateOneModel + func (uom *UpdateOneModel) SetFilter(filter interface{}) *UpdateOneModel + func (uom *UpdateOneModel) SetUpdate(update interface{}) *UpdateOneModel + func (uom *UpdateOneModel) SetUpsert(upsert bool) *UpdateOneModel + type UpdateResult struct + MatchedCount int64 + ModifiedCount int64 + UpsertedCount int64 + UpsertedID interface{} + func (result *UpdateResult) UnmarshalBSON(b []byte) error + type WriteConcernError struct + Code int + Details bson.Raw + Message string + Name string + func (wce WriteConcernError) Error() string + type WriteError struct + Code int + Index int + Message string + func (we WriteError) Error() string + type WriteErrors []WriteError + func (we WriteErrors) Error() string + type WriteException struct + WriteConcernError *WriteConcernError + WriteErrors WriteErrors + func (mwe WriteException) Error() string + type WriteModel interface