mongodb

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Username      string        `json:"username" yaml:"username"`
	Password      string        `json:"password" yaml:"password"`
	Address       string        `json:"address" yaml:"address"`
	SlowThreshold time.Duration `json:"slowThreshold" yaml:"slowThreshold"` //慢日志阈值 单位:毫秒
	Debug         bool          `json:"debug" yaml:"debug"`                 //是否打印调试日志
	DisableMetric bool          `json:"disableMetric" yaml:"disableMetric"` //是否进行监控
	DisableTrace  bool          `json:"disableTrace" yaml:"disableTrace"`   //是否进行链路追踪
}

func DefaultConfig

func DefaultConfig() Config

type WrappedClient

type WrappedClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) (*WrappedClient, error)

func (*WrappedClient) Client

func (wc *WrappedClient) Client() *mongo.Client

func (*WrappedClient) Database

func (wc *WrappedClient) Database(name string, opts ...*options.DatabaseOptions) *WrappedDatabase

func (*WrappedClient) Disconnect

func (wc *WrappedClient) Disconnect(ctx context.Context) error

func (*WrappedClient) ListDatabaseNames

func (wc *WrappedClient) ListDatabaseNames(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) ([]string, error)

func (*WrappedClient) ListDatabases

func (wc *WrappedClient) ListDatabases(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) (mongo.ListDatabasesResult, error)

func (*WrappedClient) NewClientEncryption

func (wc *WrappedClient) NewClientEncryption(opts ...*options.ClientEncryptionOptions) (*WrappedClientEncryption, error)

func (*WrappedClient) Ping

func (wc *WrappedClient) Ping(ctx context.Context, rp *readpref.ReadPref) error

func (*WrappedClient) StartSession

func (wc *WrappedClient) StartSession(opts ...*options.SessionOptions) (mongo.Session, error)

func (*WrappedClient) UseSession

func (wc *WrappedClient) UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error

func (*WrappedClient) UseSessionWithOptions

func (wc *WrappedClient) UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(mongo.SessionContext) error) error

type WrappedClientEncryption

type WrappedClientEncryption struct {
	// contains filtered or unexported fields
}

func (*WrappedClientEncryption) Close

func (wce *WrappedClientEncryption) Close(ctx context.Context) error

func (*WrappedClientEncryption) CreateDataKey

func (wce *WrappedClientEncryption) CreateDataKey(ctx context.Context, kmsProvider string, opts ...*options.DataKeyOptions) (primitive.Binary, error)

func (*WrappedClientEncryption) Decrypt

func (*WrappedClientEncryption) Encrypt

type WrappedCollection

type WrappedCollection struct {
	// contains filtered or unexported fields
}

func (*WrappedCollection) Aggregate

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

func (*WrappedCollection) BulkWrite

func (*WrappedCollection) Clone

func (*WrappedCollection) Collection

func (w *WrappedCollection) Collection() *mongo.Collection

func (*WrappedCollection) Count

func (w *WrappedCollection) Count(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*WrappedCollection) CountDocuments

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

func (*WrappedCollection) Database

func (w *WrappedCollection) Database() *mongo.Database

func (*WrappedCollection) DeleteMany

func (w *WrappedCollection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*WrappedCollection) DeleteOne

func (w *WrappedCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*WrappedCollection) Distinct

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

func (*WrappedCollection) Drop

func (w *WrappedCollection) Drop(ctx context.Context) error

func (*WrappedCollection) EstimatedDocumentCount

func (w *WrappedCollection) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)

func (*WrappedCollection) Find

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

func (*WrappedCollection) FindOne

func (w *WrappedCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

func (*WrappedCollection) FindOneAndDelete

func (w *WrappedCollection) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult

func (*WrappedCollection) FindOneAndReplace

func (w *WrappedCollection) FindOneAndReplace(ctx context.Context, filter, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult

func (*WrappedCollection) FindOneAndUpdate

func (w *WrappedCollection) FindOneAndUpdate(ctx context.Context, filter, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

func (*WrappedCollection) Indexes

func (w *WrappedCollection) Indexes() mongo.IndexView

func (*WrappedCollection) InsertMany

func (w *WrappedCollection) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*WrappedCollection) InsertOne

func (w *WrappedCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*WrappedCollection) Name

func (w *WrappedCollection) Name() string

func (*WrappedCollection) ReplaceOne

func (w *WrappedCollection) ReplaceOne(ctx context.Context, filter, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*WrappedCollection) UpdateMany

func (w *WrappedCollection) UpdateMany(ctx context.Context, filter, replacement interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*WrappedCollection) UpdateOne

func (w *WrappedCollection) UpdateOne(ctx context.Context, filter, replacement interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*WrappedCollection) Watch

func (w *WrappedCollection) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

type WrappedDatabase

type WrappedDatabase struct {
	// contains filtered or unexported fields
}

func (*WrappedDatabase) Client

func (wd *WrappedDatabase) Client() *WrappedClient

func (*WrappedDatabase) Collection

func (wd *WrappedDatabase) Collection(name string, opts ...*options.CollectionOptions) *WrappedCollection

func (*WrappedDatabase) Database

func (wd *WrappedDatabase) Database() *mongo.Database

func (*WrappedDatabase) Drop

func (wd *WrappedDatabase) Drop(ctx context.Context) error

func (*WrappedDatabase) ListCollections

func (wd *WrappedDatabase) ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (*mongo.Cursor, error)

func (*WrappedDatabase) Name

func (wd *WrappedDatabase) Name() string

func (*WrappedDatabase) ReadConcern

func (wd *WrappedDatabase) ReadConcern() *readconcern.ReadConcern

func (*WrappedDatabase) ReadPreference

func (wd *WrappedDatabase) ReadPreference() *readpref.ReadPref

func (*WrappedDatabase) RunCommand

func (wd *WrappedDatabase) RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) *mongo.SingleResult

func (*WrappedDatabase) WriteConcern

func (wd *WrappedDatabase) WriteConcern() *writeconcern.WriteConcern

type WrappedSession

type WrappedSession struct {
	mongo.Session
	// contains filtered or unexported fields
}

func (*WrappedSession) AbortTransaction

func (w *WrappedSession) AbortTransaction(ctx context.Context) error

func (*WrappedSession) AdvanceClusterTime

func (w *WrappedSession) AdvanceClusterTime(br bson.Raw) error

func (*WrappedSession) AdvanceOperationTime

func (w *WrappedSession) AdvanceOperationTime(pt *primitive.Timestamp) error

func (*WrappedSession) ClusterTime

func (w *WrappedSession) ClusterTime() bson.Raw

func (*WrappedSession) CommitTransaction

func (w *WrappedSession) CommitTransaction(ctx context.Context) error

func (*WrappedSession) EndSession

func (w *WrappedSession) EndSession(ctx context.Context)

func (*WrappedSession) OperationTime

func (w *WrappedSession) OperationTime() *primitive.Timestamp

func (*WrappedSession) StartTransaction

func (w *WrappedSession) StartTransaction(opts ...*options.TransactionOptions) error

Jump to

Keyboard shortcuts

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