mongodb

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(ctx context.Context, col string, query []bson.M, value interface{}) error

func Count

func Count(ctx context.Context, col string) (int64, error)

func CountWithFilter

func CountWithFilter(ctx context.Context, col string, filter interface{}) (int64, error)

func CountWithQuery

func CountWithQuery(ctx context.Context, col string, query any) (int, error)

func DeleteOne

func DeleteOne(ctx context.Context, col string, query bson.M) (mongo.DeleteResult, error)

func FindOne

func FindOne(ctx context.Context, col string, query bson.M, value interface{}) error

func GetMongoClient added in v0.0.13

func GetMongoClient() *mongo.Client

func GetMongoDb

func GetMongoDb() *mongo.Database

GetMongoDb function returns a pointer to the `mongo.Database` instance used to communicate with MongoDB server. The function simply returns the MongoDB client instance stored in a `mongodb` singleton object. This function is used to obtain the MongoDB client connection in other parts of the application.

func Init

func Init(cp DatabaseCredentialHelper, host string, port string, database string)

Initializes the mongodb client

func InsertOne

func InsertOne(ctx context.Context, col string, input interface{}) (mongo.InsertOneResult, error)

func Ping

func Ping() bool

Ping the mongodb database and returns the result as a bool

func UpdateOne

func UpdateOne(ctx context.Context, col string, filter bson.M, update bson.M) (mongo.UpdateResult, error)

Types

type DatabaseCredentialHelper

type DatabaseCredentialHelper interface {
	GetCredentials() (string, string)
	CheckAndRenew() bool
}

Jump to

Keyboard shortcuts

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