Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( FailedToConnectError = errors.New("failed to connect to MongoDB") AlreadyConnectedError = errors.New("connection to MongoDB already established") NotConnectedError = errors.New("connection to MongoDB not established") FailedToDisconnectError = errors.New("failed to disconnect from MongoDB") FailedToCreateDocumentError = errors.New("failed to create document") FailedToStartSessionError = errors.New("failed to start session") FailedToPingError = errors.New("failed to ping MongoDB") FailedToCreateSingleFieldIndexError = errors.New("failed to create single field index") FailedToCreateCompoundIndexError = errors.New("failed to create compound index") )
Functions ¶
func LoadMongoDBName ¶ added in v0.3.0
LoadMongoDBName load MongoDB database name from environment variables
func LoadMongoDBURI ¶ added in v0.3.0
LoadMongoDBURI load MongoDB URI from environment variables
Types ¶
type Collection ¶ added in v0.1.3
type Collection struct { Name string SingleFieldIndexes *[]*SingleFieldIndex CompoundIndexes *[]*CompoundFieldIndex }
Collection represents a MongoDB collection
func NewCollection ¶ added in v0.1.3
func NewCollection(name string, singleFieldIndexes *[]*SingleFieldIndex, compoundIndexes *[]*CompoundFieldIndex) *Collection
NewCollection creates a new MongoDB collection
func (*Collection) CreateCollection ¶ added in v0.1.5
func (c *Collection) CreateCollection(database *mongo.Database) (collection *mongo.Collection, err error)
CreateCollection creates the collection
type CompoundFieldIndex ¶ added in v0.1.3
type CompoundFieldIndex struct {
Model *mongo.IndexModel
}
CompoundFieldIndex represents a compound field index
func NewCompoundFieldIndex ¶ added in v0.1.3
func NewCompoundFieldIndex(fieldIndexes []*FieldIndex, unique bool) *CompoundFieldIndex
NewCompoundFieldIndex creates a new compound field index
type ConnectionHandler ¶ added in v0.4.0
type ConnectionHandler interface { Connect() error Disconnect() }
ConnectionHandler interface
type DefaultConnectionHandler ¶ added in v0.4.0
type DefaultConnectionHandler struct { Ctx context.Context Cancel context.CancelFunc ClientOptions *options.ClientOptions Client *mongo.Client }
DefaultConnectionHandler struct
func NewDefaultConnectionHandler ¶ added in v0.4.0
func NewDefaultConnectionHandler(config *Config) *DefaultConnectionHandler
NewDefaultConnectionHandler creates a new connection
func (*DefaultConnectionHandler) Connect ¶ added in v0.4.0
func (d *DefaultConnectionHandler) Connect() error
Connect returns a new MongoDB client
func (*DefaultConnectionHandler) Disconnect ¶ added in v0.4.0
func (d *DefaultConnectionHandler) Disconnect()
Disconnect closes the MongoDB client connection
type FieldIndex ¶ added in v0.1.3
func NewFieldIndex ¶ added in v0.1.3
func NewFieldIndex(name string, order Order) *FieldIndex
NewFieldIndex creates a new field index
type Logger ¶ added in v0.3.0
type Logger struct {
// contains filtered or unexported fields
}
Logger is the logger for the MongoDB model
func NewLogger ¶ added in v0.3.0
func NewLogger(logger commonlogger.Logger) Logger
NewLogger is the logger for the MongoDB model
func (Logger) ConnectedToMongoDB ¶ added in v0.3.0
func (l Logger) ConnectedToMongoDB()
ConnectedToMongoDB logs a success message when the server connects from MongoDB
func (Logger) DisconnectedFromMongoDB ¶ added in v0.3.0
func (l Logger) DisconnectedFromMongoDB()
DisconnectedFromMongoDB logs a success message when the server disconnects from MongoDB
type SingleFieldIndex ¶ added in v0.1.3
type SingleFieldIndex struct {
Model *mongo.IndexModel
}
func NewSingleFieldIndex ¶ added in v0.1.3
func NewSingleFieldIndex(fieldIndex FieldIndex, unique bool) *SingleFieldIndex
NewSingleFieldIndex creates a new single field index