mongokit

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mongokit provides helper to interact with mongodb storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromConfig

func NewFromConfig(v config.KVStore, path string) (*mongo.Database, error)

NewFromConfig returns mongo *mongo.Database instance from yaml config file

given config file contents:

	db:
	  primary:
	    username: <username>
	    password: "<password>"
	    host: mymongo.host.com
	    port: 270017
	    schema: mymongo_db
	    auth-db: admin
	    conn:
		  max-idle: 20
		  max-lifetime: 10m
		  timeout: 5m
		  max-open: 100

 then we can call using :

	 v := viper.New()
	 ... set v file configs, etc

	 db, err := log.NewFromConfig(v, "db.primary")
	 ...continue using db.

func NewMongoDBClient

func NewMongoDBClient(opt *db.Option, authDB string) (*mongo.Database, error)

NewMongoDBClient returns new mongodb client using the go mongo-driver.

Types

This section is empty.

Jump to

Keyboard shortcuts

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