Documentation ¶
Index ¶
- func UnWrapClient(cl Client) *mongo.Client
- func UnWrapCollection(co Collection) *mongo.Collection
- func UnWrapDatabase(db Database) *mongo.Database
- func UnWrapSession(ss Session) mongo.Session
- func WithSession(ctx context.Context, sess Session, fn func(sc SessionContext) error) error
- type ChangeStream
- type Client
- type ClientEncryption
- type Collection
- type Cursor
- type Database
- type IndexView
- type SearchIndexView
- type Session
- type SessionContext
- type SingleResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnWrapClient ¶ added in v1.0.0
UnWrapClient returns original mongo.Client
func UnWrapCollection ¶ added in v1.8.2
func UnWrapCollection(co Collection) *mongo.Collection
UnWrapCollection returns original mongo.Collection
func UnWrapDatabase ¶ added in v1.8.2
UnWrapDatabase returns original mongo.Database
func UnWrapSession ¶ added in v1.8.2
UnWrapSession returns original mongo.Session
func WithSession ¶
WithSession is a wrapper for `mongo.WithSession` function to call then `mongo.WithSession` function Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#WithSession
Types ¶
type ChangeStream ¶
type ChangeStream interface { Current() bson.Raw Close(ctx context.Context) error Decode(val interface{}) error Err() error ID() int64 Next(ctx context.Context) bool ResumeToken() bson.Raw SetBatchSize(size int32) TryNext(ctx context.Context) bool }
ChangeStream is an interface for `mongo.ChangeStream` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#ChangeStream
type Client ¶
type Client interface { Connect(ctx context.Context) error Database(name string, opts ...*options.DatabaseOptions) Database Disconnect(ctx context.Context) error ListDatabaseNames( ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions, ) ([]string, error) ListDatabases( ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions, ) (mongo.ListDatabasesResult, error) NumberSessionsInProgress() int Ping(ctx context.Context, rp *readpref.ReadPref) error StartSession(opts ...*options.SessionOptions) (Session, error) Timeout() *time.Duration UseSession( ctx context.Context, fn func(sc SessionContext) error, ) error UseSessionWithOptions( ctx context.Context, opts *options.SessionOptions, fn func(sc SessionContext) error, ) error Watch( ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions, ) (ChangeStream, error) }
Client is an interface for `mongo.Client` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Client
func Connect ¶
Connect is a wrapper for `mongo.Connect` function to return the object as `Client` interface Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Connect
func NewClient
deprecated
func NewClient(opts ...*options.ClientOptions) (Client, error)
NewClient is a wrapper for `mongo.NewClient` function to return the object as `Client` interface Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#NewClient
Deprecated: Use Connect instead.
func WrapClient ¶
WrapClient returns an instance of Client interface for given mongo.Client object
type ClientEncryption ¶ added in v1.13.0
type ClientEncryption interface { AddKeyAltName( ctx context.Context, id primitive.Binary, keyAltName string, ) SingleResult Close(ctx context.Context) error CreateDataKey( ctx context.Context, kmsProvider string, opts ...*options.DataKeyOptions, ) (primitive.Binary, error) CreateEncryptedCollection( ctx context.Context, db Database, coll string, createOpts *options.CreateCollectionOptions, kmsProvider string, masterKey interface{}, ) (Collection, bson.M, error) Decrypt(ctx context.Context, val primitive.Binary) (bson.RawValue, error) DeleteKey(ctx context.Context, id primitive.Binary) (*mongo.DeleteResult, error) Encrypt( ctx context.Context, val bson.RawValue, opts ...*options.EncryptOptions, ) (primitive.Binary, error) EncryptExpression( ctx context.Context, expr interface{}, result interface{}, opts ...*options.EncryptOptions, ) error GetKey(ctx context.Context, id primitive.Binary) SingleResult GetKeyByAltName(ctx context.Context, keyAltName string) SingleResult GetKeys(ctx context.Context) (Cursor, error) RemoveKeyAltName( ctx context.Context, id primitive.Binary, keyAltName string, ) SingleResult RewrapManyDataKey( ctx context.Context, filter interface{}, opts ...*options.RewrapManyDataKeyOptions, ) (*mongo.RewrapManyDataKeyResult, error) }
ClientEncryption is an interface for `mongo.ClientEncryption` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#ClientEncryption
func NewClientEncryption ¶ added in v1.13.0
func NewClientEncryption(keyVaultClient Client, opts ...*options.ClientEncryptionOptions) (ClientEncryption, error)
type Collection ¶
type Collection interface { Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (Cursor, error) BulkWrite( ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions, ) (*mongo.BulkWriteResult, error) Clone(opts ...*options.CollectionOptions) (Collection, error) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error) Database() Database DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) Distinct( ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions, ) ([]interface{}, error) Drop(ctx context.Context) error EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (Cursor, error) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) SingleResult FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) SingleResult FindOneAndReplace( ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions, ) SingleResult FindOneAndUpdate( ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions, ) SingleResult Indexes() IndexView InsertMany( ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions, ) (*mongo.InsertManyResult, error) InsertOne( ctx context.Context, document interface{}, opts ...*options.InsertOneOptions, ) (*mongo.InsertOneResult, error) Name() string ReplaceOne( ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions, ) (*mongo.UpdateResult, error) SearchIndexes() SearchIndexView UpdateByID( ctx context.Context, id interface{}, update interface{}, opts ...*options.UpdateOptions, ) (*mongo.UpdateResult, error) UpdateMany( ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions, ) (*mongo.UpdateResult, error) UpdateOne( ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions, ) (*mongo.UpdateResult, error) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (ChangeStream, error) }
Collection is an interface for `mongo.Collection` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection
func WrapCollection ¶ added in v1.8.2
func WrapCollection(co *mongo.Collection) Collection
WrapCollection returns an instance of Collection interface for given mongo.Collection object
type Cursor ¶
type Cursor interface { Current() bson.Raw All(ctx context.Context, results interface{}) error Close(ctx context.Context) error Decode(val interface{}) error Err() error ID() int64 Next(ctx context.Context) bool RemainingBatchLength() int SetBatchSize(batchSize int32) SetComment(comment interface{}) SetMaxTime(dur time.Duration) TryNext(ctx context.Context) bool }
Cursor is an interface for `mongo.Cursor` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor
func NewCursorFromDocuments ¶ added in v1.9.0
func NewCursorFromDocuments(documents []interface{}, err error, registry *bsoncodec.Registry) (Cursor, error)
NewCursorFromDocuments is a wrapper for NewCursorFromDocuments function of the mongodb to return Cursor https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#NewCursorFromDocuments
type Database ¶
type Database interface { Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (Cursor, error) Client() Client Collection(name string, opts ...*options.CollectionOptions) Collection CreateCollection(ctx context.Context, name string, opts ...*options.CreateCollectionOptions) error CreateView( ctx context.Context, viewName, viewOn string, pipeline interface{}, opts ...*options.CreateViewOptions, ) error Drop(ctx context.Context) error ListCollectionNames( ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions, ) ([]string, error) ListCollectionSpecifications( ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions, ) ([]*mongo.CollectionSpecification, error) ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (Cursor, error) Name() string ReadConcern() *readconcern.ReadConcern ReadPreference() *readpref.ReadPref RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) SingleResult RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (Cursor, error) Watch( ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions, ) (ChangeStream, error) WriteConcern() *writeconcern.WriteConcern }
Database is an interface for `mongo.Database` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Database
func WrapDatabase ¶ added in v1.8.2
WrapDatabase returns an instance of Database interface for given mongo.Database object
type IndexView ¶
type IndexView interface { CreateMany(ctx context.Context, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error) CreateOne(ctx context.Context, model mongo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error) DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error) DropOneWithKey( ctx context.Context, keySpecDocument interface{}, opts ...*options.DropIndexesOptions, ) (bson.Raw, error) List(ctx context.Context, opts ...*options.ListIndexesOptions) (Cursor, error) ListSpecifications(ctx context.Context, opts ...*options.ListIndexesOptions) ([]*mongo.IndexSpecification, error) }
IndexView is an interface for `mongo.IndexView` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#IndexView
type SearchIndexView ¶ added in v1.13.0
type SearchIndexView interface { CreateMany( ctx context.Context, models []mongo.SearchIndexModel, opts ...*options.CreateSearchIndexesOptions, ) ([]string, error) CreateOne( ctx context.Context, model mongo.SearchIndexModel, opts ...*options.CreateSearchIndexesOptions, ) (string, error) DropOne( ctx context.Context, name string, opts ...*options.DropSearchIndexOptions, ) error List( ctx context.Context, searchIdxOpts *options.SearchIndexesOptions, opts ...*options.ListSearchIndexesOptions, ) (Cursor, error) UpdateOne( ctx context.Context, name string, definition interface{}, opts ...*options.UpdateSearchIndexOptions, ) error }
SearchIndexView is an interface for `mongo.SearchIndexView` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SearchIndexView
type Session ¶
type Session interface { StartTransaction(opts ...*options.TransactionOptions) error AbortTransaction(ctx context.Context) error CommitTransaction(ctx context.Context) error WithTransaction( ctx context.Context, fn func(sc SessionContext) (interface{}, error), opts ...*options.TransactionOptions, ) (interface{}, error) EndSession(ctx context.Context) ClusterTime() bson.Raw OperationTime() *primitive.Timestamp Client() Client ID() bson.Raw AdvanceClusterTime(bson.Raw) error AdvanceOperationTime(*primitive.Timestamp) error }
Session is an interface for `mongo.Session` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Session
func SessionFromContext ¶ added in v1.10.1
SessionFromContext for `mongo.SessionFromContext` Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SessionFromContext
func WrapSession ¶ added in v1.8.2
WrapSession returns an instance of Session interface for given mongo.Session object
type SessionContext ¶ added in v1.0.0
SessionContext is an interface emulates `mongo.SessionContext` Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SessionContext
func NewSessionContext ¶ added in v1.10.1
func NewSessionContext(ctx context.Context, sess Session) SessionContext
NewSessionContext is wrapper for `mongo.NewSessionContext` Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#NewSessionContext
type SingleResult ¶
type SingleResult interface { Decode(v interface{}) error DecodeBytes() (bson.Raw, error) Err() error Raw() (bson.Raw, error) }
SingleResult is an interface for `mongo.SingleResult` structure Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SingleResult
func NewSingleResultFromDocument ¶ added in v1.9.0
func NewSingleResultFromDocument(document interface{}, err error, registry *bsoncodec.Registry) SingleResult
NewSingleResultFromDocument is a wrapper for NewSingleResultFromDocument function of the mongodb to return SingleResult https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#NewSingleResultFromDocument