Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func SetConnectionConfig ¶
func SetConnectionConfig(clusterName string, config *ConnectionConfig)
func SetConnectionConfigE ¶
func SetConnectionConfigE(clusterName string, config *ConnectionConfig) error
Types ¶
type Client ¶
type Client interface {
Database(string, ...options.Lister[options.DatabaseOptions]) Database
Disconnect(context.Context) error
StartSession() (*mongo.Session, error)
UseSession(ctx context.Context, fn func(context.Context) error) error
Ping(context.Context) error
}
func ConnectContext ¶
type Collection ¶
type Collection interface {
FindOne(context.Context, interface{}, ...options.Lister[options.FindOneOptions]) SingleResult
InsertOne(context.Context, interface{}, ...options.Lister[options.InsertOneOptions]) (interface{}, error)
InsertMany(context.Context, []interface{}, ...options.Lister[options.InsertManyOptions]) ([]interface{}, error)
DeleteOne(context.Context, interface{}, ...options.Lister[options.DeleteOneOptions]) (int64, error)
DeleteMany(context.Context, interface{}, ...options.Lister[options.DeleteManyOptions]) (int64, error)
Find(context.Context, interface{}, ...options.Lister[options.FindOptions]) (Cursor, error)
CountDocuments(context.Context, interface{}, ...options.Lister[options.CountOptions]) (int64, error)
Aggregate(context.Context, interface{}, ...options.Lister[options.AggregateOptions]) (Cursor, error)
UpdateOne(context.Context, interface{}, interface{}, ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)
UpdateMany(context.Context, interface{}, interface{}, ...options.Lister[options.UpdateManyOptions]) (*mongo.UpdateResult, error)
FindOneAndUpdate(context.Context, interface{}, interface{}, ...options.Lister[options.FindOneAndUpdateOptions]) SingleResult
BulkWrite(context.Context, []mongo.WriteModel, ...options.Lister[options.BulkWriteOptions]) (*mongo.BulkWriteResult, error)
}
type ConnectionConfig ¶
type ConnectionConfig struct {
Hosts []string
Username string
Password string
ConnectionTimeout time.Duration
ConnectionPoolsize int64
}
func (*ConnectionConfig) Validate ¶
func (c *ConnectionConfig) Validate() error
type Database ¶
type Database interface {
Collection(string, ...options.Lister[options.CollectionOptions]) Collection
}
type MongoConnector ¶
type MongoDbConnector ¶
type MongoDbConnector struct {
DB Client
}
MongoDbConnector provides a struct implementation for the MongoDbConnectorInterface. It contains a DB field which represents the active MongoDB connection.
func (*MongoDbConnector) Connect ¶
func (mdc *MongoDbConnector) Connect(ctx context.Context, clientOpts *options.ClientOptions) (Client, error)
type SingleResult ¶
type SingleResult interface {
Decode(interface{}) error
}
Click to show internal directories.
Click to hide internal directories.