Documentation ¶
Index ¶
- Variables
- func CheckEnvVar(env string)
- func EnvMongoDB() string
- func EnvMongoURI() string
- func GetCollection(client *mongo.Client, collectionName string) *mongo.Collection
- func GetCount(ctx context.Context, collection *mongo.Collection, match bson.M) (int64, error)
- func GetFindOnlyMatchResults(ctx context.Context, coll *mongo.Collection, match bson.M) (*mongo.Cursor, error)
- func GetFindQueryResults(ctx context.Context, coll *mongo.Collection, match bson.M, sort bson.D, ...) (*mongo.Cursor, error)
- func GetMongoClient() *mongo.Client
- func InitialChecks()
- func InitializeClient()
- func Insert(ctx context.Context, collection *mongo.Collection, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ConnectionTimeout = 100
View Source
var DB string
View Source
var DBClient *mongo.Client
View Source
var EnvFile string
View Source
var MaxLimit = int64(10000)
View Source
var Timeout = time.Duration(ConnectionTimeout) * time.Second
View Source
var URI string
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 GetCollection ¶
func GetCollection(client *mongo.Client, collectionName string) *mongo.Collection
GetCollection returns Mongo db collection with the given collection name
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 InitialChecks ¶
func InitialChecks()
func InitializeClient ¶
func InitializeClient()
InitializeClient setup client connection in main function
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.