mongo

package
v2.2.0-20240131 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortTransaction

func AbortTransaction(session mongo.Session) error

func Client

func Client() *mongo.Client

func Close

func Close(ctx context.Context) error

func CommitTransaction

func CommitTransaction(session mongo.Session) error

func Database

func Database(name string) *mongo.Database

func ExtractDatabaseName

func ExtractDatabaseName(uri string) (dbName, extractedURI string, err error)

ExtractDatabaseName extracts database name from uri if exists, and returns it together with the extracted uri (without database name) ref: https://docs.mongodb.com/manual/reference/connection-string/

func Init

func Init(ctx context.Context, uri string)

Init is a singleton, it will be initialized only once. In case the uri provides only a single host in the mongodb cluster, the system will attempt to connect without discovering other hosts in the cluster.

func InitWithOption

func InitWithOption(ctx context.Context, opt *options.ClientOptions)

InitWithOption is a singleton, it will be initialized only once.

func Ping

func Ping(ctx context.Context) error

func Session

func Session() mongo.Session

func SessionContext

func SessionContext(ctx context.Context, session mongo.Session) context.Context

func StartTransaction

func StartTransaction(session mongo.Session) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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