mongodb

package
v2.9.9 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeCreate

func BeforeCreate(document interface{}) interface{}

BeforeCreate ...

func BeforeUpdate

func BeforeUpdate(document interface{}) interface{}

BeforeUpdate ...

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

NewClient 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