gomongo

package
v1.2.63 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

golang mongodb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(configs ...Config) (err error)

可以一次初始化多个Mongo实例或者 多次调用初始化多个实例

Types

type Config

type Config struct {
	Name           string `yaml:"Name" json:"name,optional"`
	Addr           string `yaml:"Addr" json:"addr,optional"`
	User           string `yaml:"User" json:"user,optional"`
	Password       string `yaml:"Password" json:"password,optional"`
	EnablePassword bool   `yaml:"EnablePassword" json:"enablePassword,optional"`
	Database       string `yaml:"Database" json:"database,optional"`
	AutoPing       bool   `yaml:"AutoPing" json:"autoPing,optional"`
}

type GoMongo

type GoMongo struct {
	*mongo.Client
	// contains filtered or unexported fields
}

func Default

func Default() *GoMongo

func GetClient

func GetClient(names ...string) *GoMongo

func New

func New(conf Config) (cli *GoMongo, err error)

func (*GoMongo) DB

func (cli *GoMongo) DB() *mongo.Database

func (*GoMongo) WithContext

func (cli *GoMongo) WithContext(ctx context.Context) *GoMongo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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