mongodb

package
v3.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeCreate

func BeforeCreate(document interface{}) interface{}

func BeforeUpdate

func BeforeUpdate(document interface{}) interface{}

Types

type Config

type Config struct {
	URI             string
	MaxConnIdleTime time.Duration
	MaxPoolSize     uint64
	MinPoolSize     uint64
	DisableMetric   bool // 关闭指标采集
	DisableTrace    bool // 关闭链路追踪
}

Config 配置

type MongoDB

type MongoDB struct {
	Client        *mongo.Client
	Name          string
	DisableMetric bool // 关闭指标采集
	DisableTrace  bool // 关闭链路追踪
}

MongoDB 连接

func NewClient

func NewClient(config *Config) *MongoDB

New 数据库连接

func (*MongoDB) Collection

func (client *MongoDB) Collection(table string) *collection

Collection 得到一个mongo操作对象

Jump to

Keyboard shortcuts

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