Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct { DB string `mapstructure:"db" yaml:"db"` // Name of the database. Host string `mapstructure:"host" yaml:"host"` // URL to reach the mongoDB server. Port int `mapstructure:"port,omitempty" yaml:"port,omitempty"` // Optionnal port, if set to 0 it won't be processed. Username string `mapstructure:"username" yaml:"username"` // Credential to authenticate to the db. Password string `mapstructure:"password" yaml:"password"` // Credential to authenticate to the db. AuthSource string `mapstructure:"auth_source" yaml:"auth_source"` // Database to check authentication Timeout int `mapstructure:"timeout" yaml:"timeout"` // Connection timeout in seconds Options map[string]string `mapstructure:"options" yaml:"options"` // List of connection options }
Conf contains all information to connect to a MongoDB server.
type Connector ¶
Connector is the connector used to communicate with MongoDB database server. It embeds a native mongo.Client so it can be used as is and is supercharged with additionnal methods.
func FactoryConnector ¶
FactoryConnector instanciates a new *Connector with the given params.
func (*Connector) Collection ¶
func (con *Connector) Collection(collectionName string) *mongo.Collection
Collection returns the *mongo.Collection identified its name. If the specified collections doesn't exists on con.Collections map then add it.
func (*Connector) TryConnection ¶
TryConnection tests ping, it end if the ping is a success or timeout.
Click to show internal directories.
Click to hide internal directories.