gomongo

package
v1.2.133 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

golang mongodb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelClient added in v1.2.108

func DelClient(names ...string)

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