Documentation ¶
Index ¶
- Constants
- func NewMongoDatabaseClient(config database.DatabaseConfiguration) (database.DatabaseClient, error)
- type MongoDatabaseClient
- func (repo *MongoDatabaseClient) Connect(ctx context.Context, timeout time.Duration) (err error)
- func (repo *MongoDatabaseClient) Count(ctx context.Context, collection string, qb query.QueryBuilder) (uint64, error)
- func (repo *MongoDatabaseClient) DeleteOne(ctx context.Context, collection string, qb query.QueryBuilder) error
- func (repo *MongoDatabaseClient) Disconnect(ctx context.Context) error
- func (repo *MongoDatabaseClient) Find(ctx context.Context, collection string, qb query.QueryBuilder, ...) error
- func (repo *MongoDatabaseClient) FindOne(ctx context.Context, collection string, qb query.QueryBuilder, ...) error
- func (repo *MongoDatabaseClient) InsertOne(ctx context.Context, collection string, payload interface{}) (string, error)
- func (repo *MongoDatabaseClient) UpdateOne(ctx context.Context, collection string, qb query.QueryBuilder, ...) error
- type ObjectID
Constants ¶
const ( // User is the name of the config variable for a client connection User = "user" // Pass is the name of the config variable for a client connection Pass = "pass" // Host is the name of the config variable for a client connection Host = "host" // Port is the name of the config variable for a client connection Port = "port" // DBName is the name of the config variable for a client connection DBName = "db_name" )
Variables ¶
This section is empty.
Functions ¶
func NewMongoDatabaseClient ¶
func NewMongoDatabaseClient( config database.DatabaseConfiguration, ) (database.DatabaseClient, error)
NewMongoDatabaseClient creates a new instance of DatabaseClient to connect with Mongo databases
Types ¶
type MongoDatabaseClient ¶
type MongoDatabaseClient struct {
// contains filtered or unexported fields
}
MongoDatabaseClient defines a handler to manage actions against Mongo databases
func (*MongoDatabaseClient) Connect ¶
Disconnect performs any action to proper connect and create a connection with the database
func (*MongoDatabaseClient) Count ¶ added in v1.31.0
func (repo *MongoDatabaseClient) Count( ctx context.Context, collection string, qb query.QueryBuilder, ) (uint64, error)
Count returns the number of records in the table/collection
func (*MongoDatabaseClient) DeleteOne ¶
func (repo *MongoDatabaseClient) DeleteOne( ctx context.Context, collection string, qb query.QueryBuilder, ) error
DeleteOne deletes a single record in database
func (*MongoDatabaseClient) Disconnect ¶
func (repo *MongoDatabaseClient) Disconnect(ctx context.Context) error
Disconnect performs any action to proper disconnect and close any connection with the database
func (*MongoDatabaseClient) Find ¶
func (repo *MongoDatabaseClient) Find( ctx context.Context, collection string, qb query.QueryBuilder, target interface{}, ) error
Find returns multiple records from the database
func (*MongoDatabaseClient) FindOne ¶
func (repo *MongoDatabaseClient) FindOne( ctx context.Context, collection string, qb query.QueryBuilder, target interface{}, ) error
FindOne fetches a single record in database
func (*MongoDatabaseClient) InsertOne ¶
func (repo *MongoDatabaseClient) InsertOne( ctx context.Context, collection string, payload interface{}, ) (string, error)
InsertOne stores a single record in database and returns the id of the stored record
func (*MongoDatabaseClient) UpdateOne ¶
func (repo *MongoDatabaseClient) UpdateOne( ctx context.Context, collection string, qb query.QueryBuilder, payload interface{}, ) error
UpdateOne updates a single record in database
type ObjectID ¶
ObjectID is a wrapper for the original primitive.ObjectID
func NewObjectIDFromHex ¶
ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.