mongo

package
v0.0.0-...-4be1988 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseMongoClient

func CloseMongoClient()

func Count

func Count(database string, collection string, filter interface{}) (int64, error)

统计总数

func ExpireTime

func ExpireTime(database string, collection string, seconds int) error

设置失效时间 一般不通过代码设置

func FindOne

func FindOne(database string, collection string, filter, result interface{}) error

查找一条记录

func FindPage

func FindPage(database string, collection string, skip, limit int64, filter, sort, result interface{}) error

分页查询

func GetMongoClient

func GetMongoClient() *mongo.Client

func InitMongoClient

func InitMongoClient(urlMongo, user, password string) error

main 中初始化连接

func Insert

func Insert(database string, collection string, doc interface{}) error

添加一条记录

func InsertExpire

func InsertExpire(database string, collection string, doc interface{}, seconds int) error

添加一条记录设置失效时间

func InsertMany

func InsertMany(database string, collection string, docs ...interface{}) error

添加多条记录

func Remove

func Remove(database string, collection string, filter interface{}) error

删除一条记录

func RemoveMany

func RemoveMany(database string, collection string, filter interface{}) error

删除多条记录

func TimeoutContext

func TimeoutContext() context.Context

func Update

func Update(database string, collection string, filter, update interface{}) error

更新一条记录

func UpdateMany

func UpdateMany(database string, collection string, filter, update interface{}) error

更新多条记录

Types

This section is empty.

Jump to

Keyboard shortcuts

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