eMongo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoInit = errors.New("eMongo: please initialize with eMongo.Init()")

Functions

func GetClient

func GetClient(conf Conf) (*mongo.Client, error)

func GetCollection

func GetCollection(name string, collection string, opts ...*options.CollectionOptions) *mongo.Collection

func Init

func Init(c map[string]Conf)

Init 初始化 Example:

c = map[string]Conf{
		"localhost": {
			Host:     viper.GetString("MONGO_RW_HOST"),
			Port:     viper.GetInt("MONGO_RW_PORT"),
			Database: viper.GetString("MONGO_RW_DATABASE"),
			User:     viper.GetString("MONGO_RW_USERNAME"),
			Password: viper.GetString("MONGO_RW_PASSWORD"),
		},
	}

@param c

Types

type Conf

type Conf struct {
	Host     string
	Port     int
	Database string
	User     string
	Password string
}

type EMongo

type EMongo struct {
	ConfName   string
	Collection string
}

func (*EMongo) MDB

func (ctl *EMongo) MDB(opts ...*options.CollectionOptions) *mongo.Collection

Jump to

Keyboard shortcuts

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