Versions in this module Expand all Collapse all v1 v1.10.11 Oct 31, 2022 v1.10.10 Oct 31, 2022 v1.10.9 Oct 31, 2022 v1.10.8 Oct 31, 2022 v1.10.7 Oct 31, 2022 v1.10.6 Oct 31, 2022 v1.10.5 Oct 31, 2022 v1.10.4 Oct 31, 2022 v1.10.3 Oct 28, 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 ErrNilValue = errors.New("value 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 IsDuplicateKeyError(err error) bool + func IsNetworkError(err error) bool + func IsTimeout(err error) bool + 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 + Labels []string + WriteConcernError *WriteConcernError + WriteErrors []BulkWriteError + func (bwe BulkWriteException) Error() string + func (bwe BulkWriteException) HasErrorCode(code int) bool + func (bwe BulkWriteException) HasErrorCodeWithMessage(code int, message string) bool + func (bwe BulkWriteException) HasErrorLabel(label string) bool + func (bwe BulkWriteException) HasErrorMessage(message string) bool + 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 + func (cs *ChangeStream) TryNext(ctx context.Context) bool + 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) NumberSessionsInProgress() int + func (c *Client) Ping(ctx context.Context, rp *readpref.ReadPref) error + func (c *Client) StartSession(opts ...*options.SessionOptions) (Session, error) + func (c *Client) Timeout() *time.Duration + 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 ClientEncryption struct + func NewClientEncryption(keyVaultClient *Client, opts ...*options.ClientEncryptionOptions) (*ClientEncryption, error) + func (ce *ClientEncryption) AddKeyAltName(ctx context.Context, id primitive.Binary, keyAltName string) *SingleResult + func (ce *ClientEncryption) Close(ctx context.Context) error + func (ce *ClientEncryption) CreateDataKey(ctx context.Context, kmsProvider string, opts ...*options.DataKeyOptions) (primitive.Binary, error) + func (ce *ClientEncryption) Decrypt(ctx context.Context, val primitive.Binary) (bson.RawValue, error) + func (ce *ClientEncryption) DeleteKey(ctx context.Context, id primitive.Binary) (*DeleteResult, error) + func (ce *ClientEncryption) Encrypt(ctx context.Context, val bson.RawValue, opts ...*options.EncryptOptions) (primitive.Binary, error) + func (ce *ClientEncryption) GetKey(ctx context.Context, id primitive.Binary) *SingleResult + func (ce *ClientEncryption) GetKeyByAltName(ctx context.Context, keyAltName string) *SingleResult + func (ce *ClientEncryption) GetKeys(ctx context.Context) (*Cursor, error) + func (ce *ClientEncryption) RemoveKeyAltName(ctx context.Context, id primitive.Binary, keyAltName string) *SingleResult + func (ce *ClientEncryption) RewrapManyDataKey(ctx context.Context, filter interface{}, ...) (*RewrapManyDataKeyResult, 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) (cur *Cursor, err 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) UpdateByID(ctx context.Context, id interface{}, update 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 CollectionSpecification struct + IDIndex *IndexSpecification + Name string + Options bson.Raw + ReadOnly bool + Type string + UUID *primitive.Binary + func (cs *CollectionSpecification) UnmarshalBSON(data []byte) error + type CommandError struct + Code int32 + Labels []string + Message string + Name string + Raw bson.Raw + Wrapped error + func (e CommandError) Error() string + func (e CommandError) HasErrorCode(code int) bool + func (e CommandError) HasErrorCodeWithMessage(code int, message string) bool + func (e CommandError) HasErrorLabel(label string) bool + func (e CommandError) HasErrorMessage(message string) bool + func (e CommandError) IsMaxTimeMSExpiredError() bool + func (e CommandError) Unwrap() error + type Cursor struct + Current bson.Raw + func NewCursorFromDocuments(documents []interface{}, err error, registry *bsoncodec.Registry) (*Cursor, error) + 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 + func (c *Cursor) RemainingBatchLength() int + func (c *Cursor) TryNext(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) CreateCollection(ctx context.Context, name string, opts ...*options.CreateCollectionOptions) error + func (db *Database) CreateView(ctx context.Context, viewName, viewOn string, pipeline interface{}, ...) error + func (db *Database) Drop(ctx context.Context) error + func (db *Database) ListCollectionNames(ctx context.Context, filter interface{}, ...) ([]string, error) + func (db *Database) ListCollectionSpecifications(ctx context.Context, filter interface{}, ...) ([]*CollectionSpecification, 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{} + Hint interface{} + func NewDeleteManyModel() *DeleteManyModel + func (dmm *DeleteManyModel) SetCollation(collation *options.Collation) *DeleteManyModel + func (dmm *DeleteManyModel) SetFilter(filter interface{}) *DeleteManyModel + func (dmm *DeleteManyModel) SetHint(hint interface{}) *DeleteManyModel + type DeleteOneModel struct + Collation *options.Collation + Filter interface{} + Hint interface{} + func NewDeleteOneModel() *DeleteOneModel + func (dom *DeleteOneModel) SetCollation(collation *options.Collation) *DeleteOneModel + func (dom *DeleteOneModel) SetFilter(filter interface{}) *DeleteOneModel + func (dom *DeleteOneModel) SetHint(hint interface{}) *DeleteOneModel + type DeleteResult struct + DeletedCount int64 + type Dialer interface + DialContext func(ctx context.Context, network, address string) (net.Conn, error) + type EncryptionKeyVaultError struct + Wrapped error + func (ekve EncryptionKeyVaultError) Error() string + func (ekve EncryptionKeyVaultError) Unwrap() error + type ErrMapForOrderedArgument struct + ParamName string + func (e ErrMapForOrderedArgument) Error() string + 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 IndexSpecification struct + Clustered *bool + ExpireAfterSeconds *int32 + KeysDocument bson.Raw + Name string + Namespace string + Sparse *bool + Unique *bool + Version int32 + func (i *IndexSpecification) UnmarshalBSON(data []byte) error + 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) + func (iv IndexView) ListSpecifications(ctx context.Context, opts ...*options.ListIndexesOptions) ([]*IndexSpecification, 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 MongocryptError struct + Code int32 + Message string + func (m MongocryptError) Error() string + type MongocryptdError struct + Wrapped error + func (e MongocryptdError) Error() string + func (e MongocryptdError) Unwrap() error + type Pipeline []bson.D + type ReplaceOneModel struct + Collation *options.Collation + Filter interface{} + Hint 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) SetHint(hint interface{}) *ReplaceOneModel + func (rom *ReplaceOneModel) SetReplacement(rep interface{}) *ReplaceOneModel + func (rom *ReplaceOneModel) SetUpsert(upsert bool) *ReplaceOneModel + type RewrapManyDataKeyResult struct + type ServerError interface + HasErrorCode func(int) bool + HasErrorCodeWithMessage func(int, string) bool + HasErrorLabel func(string) bool + HasErrorMessage func(string) bool + 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) + ID func() bson.Raw + OperationTime func() *primitive.Timestamp + StartTransaction func(...*options.TransactionOptions) error + WithTransaction func(ctx context.Context, fn func(sessCtx SessionContext) (interface{}, error), ...) (interface{}, error) + func SessionFromContext(ctx context.Context) Session + type SessionContext interface + func NewSessionContext(ctx context.Context, sess Session) SessionContext + type SingleResult struct + func NewSingleResultFromDocument(document interface{}, err error, registry *bsoncodec.Registry) *SingleResult + 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{} + Hint 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) SetHint(hint 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{} + Hint 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) SetHint(hint 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 + Raw bson.Raw + func (wce WriteConcernError) Error() string + func (wce WriteConcernError) IsMaxTimeMSExpiredError() bool + type WriteError struct + Code int + Details bson.Raw + Index int + Message string + Raw bson.Raw + func (we WriteError) Error() string + func (we WriteError) HasErrorCode(code int) bool + func (we WriteError) HasErrorCodeWithMessage(code int, message string) bool + func (we WriteError) HasErrorLabel(label string) bool + func (we WriteError) HasErrorMessage(message string) bool + type WriteErrors []WriteError + func (we WriteErrors) Error() string + type WriteException struct + Labels []string + Raw bson.Raw + WriteConcernError *WriteConcernError + WriteErrors WriteErrors + func (mwe WriteException) Error() string + func (mwe WriteException) HasErrorCode(code int) bool + func (mwe WriteException) HasErrorCodeWithMessage(code int, message string) bool + func (mwe WriteException) HasErrorLabel(label string) bool + func (mwe WriteException) HasErrorMessage(message string) bool + type WriteModel interface + type XSession interface + ClientSession func() *session.Client