Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewSession = func(ctx context.Context, opt config.Mongo) (ISession, error) { serverAPIOptions := options.ServerAPI(options.ServerAPIVersion1) authentication := "" database := "" permission := "?retryWrites=true&w=majority" if opt.MongoUsername != "" && opt.MongoPassword != "" { authentication = fmt.Sprintf("%s:%s@", opt.MongoUsername, opt.MongoPassword) } if opt.MongoDatabase != "" { database = fmt.Sprintf("/%s", opt.MongoDatabase) } if opt.MongoAuthSource { permission = "?authSource=admin" } if opt.MongoIgnoreQueryString { permission = "" } clientOptions := options.Client(). ApplyURI(fmt.Sprintf("%s://%s%s%s%s", opt.MongoProtocol, authentication, opt.MongoHost, database, permission)). SetServerAPIOptions(serverAPIOptions) return newClient(ctx, clientOptions) }
NewSession method
Functions ¶
This section is empty.
Types ¶
type ISession ¶
type ISession interface { Connect(ctx context.Context) error Disconnect(ctx context.Context) error Ping(ctx context.Context, rp *readpref.ReadPref) error StartSession(opts ...*options.SessionOptions) (mongo.Session, error) Database(name string, opts ...*options.DatabaseOptions) *mongo.Database ListDatabases(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) (mongo.ListDatabasesResult, error) ListDatabaseNames(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) ([]string, error) UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(mongo.SessionContext) error) error Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error) NumberSessionsInProgress() int Timeout() *time.Duration }
ISession interface
Click to show internal directories.
Click to hide internal directories.