mongo

package
v0.0.0-...-4623330 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     string
	UserName string
	Password string
	Database string
}

type Mdb

type Mdb struct {
	*Config
	// contains filtered or unexported fields
}

mongo的辅助类

func NewMdb

func NewMdb(Host string, Port string, Database string, UserName string, Password string) *Mdb

func NewMdbWithConf

func NewMdbWithConf(c *Config) (mdb *Mdb)

func NewMdbWithHost

func NewMdbWithHost(Host string) *Mdb

func (*Mdb) All

func (self *Mdb) All(collection string, query interface{}, result interface{}) error

func (*Mdb) AllSelect

func (self *Mdb) AllSelect(collection string, query interface{}, projection interface{}, result interface{}) error

返回所有复合 query 条件的item, 并且被 projection 限制返回的fields

func (*Mdb) Count

func (self *Mdb) Count(collection string, query interface{}) (n int)

func (*Mdb) CountId

func (self *Mdb) CountId(collection string, id interface{}) (n int)

func (*Mdb) DB

func (self *Mdb) DB(s *mgo.Session) *mgo.Database

func (*Mdb) Exist

func (self *Mdb) Exist(collection string, query interface{}) bool

func (*Mdb) ExistId

func (self *Mdb) ExistId(collection string, id interface{}) bool

func (*Mdb) FindId

func (self *Mdb) FindId(collection string, id interface{}, result interface{}) error

等效于: self.One(collection,bson.M{"_id":id},result)

func (*Mdb) Insert

func (self *Mdb) Insert(collection string, data ...interface{}) error

func (*Mdb) One

func (self *Mdb) One(collection string, query interface{}, result interface{}) error

func (*Mdb) OneSelect

func (self *Mdb) OneSelect(collection string, query interface{}, projection interface{}, result interface{}) error

func (*Mdb) Page

func (self *Mdb) Page(collection string, query bson.M, offset int, limit int, result interface{}) error

func (*Mdb) PageAndCount

func (self *Mdb) PageAndCount(collection string, query bson.M, offset int, limit int, result interface{}) (total int, err error)

获取页面数据和“所有”符合条件的记录“总共”的条数

func (*Mdb) Remove

func (self *Mdb) Remove(collection string, selector interface{}) error

func (*Mdb) RemoveAll

func (self *Mdb) RemoveAll(collection string, selector interface{}) error

func (*Mdb) RemoveId

func (self *Mdb) RemoveId(collection string, id interface{}) error

func (*Mdb) Session

func (self *Mdb) Session() *mgo.Session

func (*Mdb) SetId

func (self *Mdb) SetId(collection string, id interface{}, change interface{}) error

等同与UpdateId(collection,id,bson.M{"$set":change})

func (*Mdb) Update

func (self *Mdb) Update(collection string, selector, change interface{}) error

func (*Mdb) UpdateAll

func (self *Mdb) UpdateAll(collection string, selector, change interface{}) error

func (*Mdb) UpdateId

func (self *Mdb) UpdateId(collection string, id interface{}, change interface{}) error

func (*Mdb) Upsert

func (self *Mdb) Upsert(collection string, selector interface{}, change interface{}) error

func (*Mdb) WithC

func (self *Mdb) WithC(collection string, job func(*mgo.Collection) error) error

Jump to

Keyboard shortcuts

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