e_connection

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(opts ConnectionOptions) mongo.Client

func ConnectURI

func ConnectURI(uri string) mongo.Client

Simplest form of connect with just a URI and no options

func Disconnect

func Disconnect(aliases ...string) error

Disconnect a set of connections by alias or disconnect all connections if no alias is provided

@param aliases - The aliases of the connections to disconnect

func GetConnection

func GetConnection(alias ...string) mongo.Client

Get the database connection for a given alias or the default connection if no alias is provided

@param alias - The alias of the connection to get

func Off

func Off(event string, alias ...string)

Remove a listener from a connection

@param event - The event to remove the listener from

@param alias - The alias of the connection to remove the listener from

func On

func On(event string, handler func(), alias ...string)

Add a listener to a connection

@param event - The event to listen for

@param handler - The function to call when the event is triggered

@param alias - The alias of the connection to listen to

func Use

func Use(database string, alias ...string) *mongo.Database

Use a specific database on a connection

@param database - The name of the database to use

@param alias - The alias of the connection to use

func UseDefault

func UseDefault(alias ...string) *mongo.Database

Use the default database on a connection. Uses the default connection if no alias is provided

@param alias - The alias of the connection to use

Types

type ConnectionOptions

type ConnectionOptions struct {
	Alias         string
	URI           string
	ClientOptions *options.ClientOptions
	PoolMonitor   *event.PoolMonitor
}

Jump to

Keyboard shortcuts

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