mgo

package
v0.0.0-...-13c8884 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

* Create by SunXiguang 2018-12-28 Desc: mongodb命令定义

* Create by SunXigaung 2019-01-25 Desc: mgo常用方法封装

mongodb客户端库mgo封装

Index

Constants

View Source
const (
	SET     = "$set"
	UNSET   = "$unset"
	INC     = "$inc"
	ADD2SET = "$addToSet"
	EACH    = "$each"
)

Variables

This section is empty.

Functions

func GenId

func GenId(c *Collection, moduleName string, num int) (int, error)

func Init

func Init(addrs string)

url:#[mongodb://][user:pass@]host1[:port1][,host2[:port2],…][/database][?options]

Types

type Collection

type Collection struct {
	*mgo.Session
	*mgo.Collection
}

func GetCollection

func GetCollection(dbName, collectionName string) *Collection

type M

type M struct {
	bson.M
}

//////////////////////////////////////////////////////////////////////////

func NewM

func NewM() *M

func (*M) Add2Set

func (this *M) Add2Set(key string, vals ...interface{}) *M

func (*M) Inc

func (this *M) Inc(key string, val interface{}) *M

func (*M) Op

func (this *M) Op(op, key string, val interface{}) *M

func (*M) Set

func (this *M) Set(key string, val interface{}) *M

func (*M) Unset

func (this *M) Unset(key string, val interface{}) *M

Jump to

Keyboard shortcuts

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