mongox

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MongoConfPasswordDev = "123456"
View Source
const MongoConfPasswordOnline = "123456"
View Source
const MongoConfUrlDev = "127.0.0.1:28121"
View Source
const MongoConfUrlOnline = "127.0.0.1:28121"
View Source
const MongoConfUserDev = "root"
View Source
const MongoConfUserOnline = "root"

Variables

View Source
var MongoxErrInsertError = trerror.DefaultTrError("MONGO INSERT ERROR")
View Source
var MongoxErrNoData = trerror.DefaultTrError("NO DATA")
View Source
var MongoxErrNoFound = trerror.DefaultTrError("MONGO NO FOUND")

Functions

func GetContext

func GetContext() (ctx context.Context)

func MongoSetup

func MongoSetup(user, password, host string, timeout time.Duration)

初始化

func NewMgo

func NewMgo(database, collection string) *mgo

func SetConnect

func SetConnect(user, password, host string, timeout time.Duration) *mongo.Client

连接设置

Types

type Database

type Database struct {
	Mongo *mongo.Client
}
var DB *Database

type MongoConfig

type MongoConfig struct {
	MongoConfPassword string
	MongoConfUser     string
	MongoConfUrl      string
}

func GetMongoConf

func GetMongoConf(env string) (conf MongoConfig)

Jump to

Keyboard shortcuts

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