mongo

package
v0.0.0-...-21bfe33 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionTimeout = 100
View Source
var DBClient *mongo.Client
View Source
var EnvFile string
View Source
var MaxLimit = int64(10000)

Functions

func CheckEnvVar

func CheckEnvVar(env string)

CheckEnvVar helper function to check if required environment variable is set

func EnvMongoDB

func EnvMongoDB() string

EnvMongoDB returns MongoDB connection uri "MONGO_DATABASE" environment variable

func EnvMongoURI

func EnvMongoURI() string

EnvMongoURI returns "MONGOURI" environment variable

func GetCollection

func GetCollection(client *mongo.Client, collectionName string) *mongo.Collection

GetCollection returns Mongo db collection with the given collection name

func GetCount

func GetCount(ctx context.Context, collection *mongo.Collection, match bson.M) (int64, error)

GetCount returns count of query result

func GetFindOnlyMatchResults

func GetFindOnlyMatchResults(ctx context.Context, coll *mongo.Collection, match bson.M) (*mongo.Cursor, error)

GetFindOnlyMatchResults no sort, skip, limit, just match

func GetFindQueryResults

func GetFindQueryResults(ctx context.Context, coll *mongo.Collection, match bson.M, sort bson.D, skip int64, length int64) (*mongo.Cursor, error)

GetFindQueryResults returns cursor of find query results

func GetMongoClient

func GetMongoClient() *mongo.Client

GetMongoClient returns mongo client

func InitialChecks

func InitialChecks()

func InitializeClient

func InitializeClient()

InitializeClient setup client connection in main function

func Insert

func Insert(ctx context.Context, collection *mongo.Collection, data interface{}) error

Insert returns count of query result

Types

This section is empty.

Jump to

Keyboard shortcuts

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