mongo

package
v0.0.0-...-bfb5c6f Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Strong    = 1
	Monotonic = 2
)

Variables

View Source
var (
	XINGO_MONGODB_SESSION_NIL_ERR    = errors.New("DbOperate session nil.")
	XINGO_MONGODB_NOTFOUND_ERR       = errors.New("not found!")
	XINGO_MONGODB_DBFINDALL_ERR      = errors.New("DBFindAll failed,q is nil!")
	XINGO_MONGODB_OPENGRIDFILE_ERR   = errors.New("OpenGridFile failed!")
	XINGO_MONGODB_READGRIDFILE_ERR   = errors.New("ReadGridFile failed!")
	XINGO_MONGODB_CREATEGRIDFILE_ERR = errors.New("CreateGridFile is nil")
)

Functions

This section is empty.

Types

type DbCfg

type DbCfg struct {
	DbHost string
	DbPort int
	DbName string
	DbUser string
	DbPass string
}

func NewDbCfg

func NewDbCfg(host string, port int, name, user, pass string) *DbCfg

func (*DbCfg) String

func (this *DbCfg) String() string

type DbOperate

type DbOperate struct {
	// contains filtered or unexported fields
}

func NewDbOperate

func NewDbOperate(dbcfg *DbCfg, timeout time.Duration) *DbOperate

func (*DbOperate) BulkInsert

func (this *DbOperate) BulkInsert(collection string, pairs []bson.M) error

func (*DbOperate) BulkInsertDoc

func (this *DbOperate) BulkInsertDoc(collection string, docs []interface{}) error

func (*DbOperate) BulkUpdate

func (this *DbOperate) BulkUpdate(collection string, pairs []bson.M) error

func (*DbOperate) BulkUpsert

func (this *DbOperate) BulkUpsert(collection string, pairs []bson.M) error

func (*DbOperate) CloseDB

func (this *DbOperate) CloseDB()

func (*DbOperate) Cover

func (this *DbOperate) Cover(collection string, cond interface{}, change interface{}) error

func (*DbOperate) CreateGridFile

func (this *DbOperate) CreateGridFile(collection string, filename string, resHandler func(*mgo.GridFile) error) error

func (*DbOperate) DBFindAll

func (this *DbOperate) DBFindAll(collection string, cond interface{}, resHandler func(bson.M) error) error

func (*DbOperate) DBFindAllEx

func (this *DbOperate) DBFindAllEx(collection string, cond interface{}, resHandler func(*mgo.Query) error) error

func (*DbOperate) DBFindOne

func (this *DbOperate) DBFindOne(collection string, cond interface{}, resHandler func(bson.M) error) error

func (*DbOperate) DeleteAll

func (this *DbOperate) DeleteAll(collection string, cond interface{}) (int, error)

func (*DbOperate) DeleteOne

func (this *DbOperate) DeleteOne(collection string, cond interface{}) error

友情提示,如果存在多个document,会报错,请用DeleteAll

func (*DbOperate) FindAll

func (this *DbOperate) FindAll(collection string, cond interface{}, all interface{}) error

func (*DbOperate) FindAndModify

func (this *DbOperate) FindAndModify(collection string, cond interface{}, change mgo.Change, val interface{}) error

func (*DbOperate) FindOne

func (this *DbOperate) FindOne(collection string, cond interface{}, value interface{}) error

func (*DbOperate) GetDbSession

func (db *DbOperate) GetDbSession() *mgo.Session

func (*DbOperate) GetMaxId

func (this *DbOperate) GetMaxId(collection string, field string) (int64, error)

func (*DbOperate) GridFileExists

func (this *DbOperate) GridFileExists(collection string, filename string) (bool, error)

func (*DbOperate) Insert

func (this *DbOperate) Insert(collection string, doc interface{}) error

func (*DbOperate) OpenDB

func (this *DbOperate) OpenDB(set_index_func func(ms *mgo.Session)) error

func (*DbOperate) OpenGridFile

func (this *DbOperate) OpenGridFile(collection string, filename string) ([]byte, error)

gridfs

func (*DbOperate) RefreshSession

func (this *DbOperate) RefreshSession()

func (*DbOperate) RemoveAll

func (this *DbOperate) RemoveAll(collection string, cond interface{}) error

func (*DbOperate) RemoveGridFile

func (this *DbOperate) RemoveGridFile(collection string, filename string) (bool, error)

func (*DbOperate) RemoveOne

func (this *DbOperate) RemoveOne(collection string, cond_name string, cond_value int64) error

func (*DbOperate) RemoveOneByCond

func (this *DbOperate) RemoveOneByCond(collection string, cond interface{}) error

func (*DbOperate) SetMode

func (this *DbOperate) SetMode(mode int, refresh bool)

func (*DbOperate) StrongBatchInsert

func (this *DbOperate) StrongBatchInsert(collection string, docs ...interface{}) error

func (*DbOperate) StrongDBFindAll

func (this *DbOperate) StrongDBFindAll(collection string, cond interface{}, resHandler func(bson.M) error) error

func (*DbOperate) StrongDBFindAllEx

func (this *DbOperate) StrongDBFindAllEx(collection string, cond interface{}, resHandler func(*mgo.Query) error) error

func (*DbOperate) StrongDBFindOne

func (this *DbOperate) StrongDBFindOne(collection string, cond interface{}, resHandler func(bson.M) error) error

func (*DbOperate) StrongInsert

func (this *DbOperate) StrongInsert(collection string, doc interface{}) error

func (*DbOperate) StrongUpdate

func (this *DbOperate) StrongUpdate(collection string, cond interface{}, change interface{}) error

func (*DbOperate) StrongUpdateInsert

func (this *DbOperate) StrongUpdateInsert(collection string, cond interface{}, doc interface{}) error

func (*DbOperate) Update

func (this *DbOperate) Update(collection string, cond interface{}, change interface{}) error

func (*DbOperate) UpdateInsert

func (this *DbOperate) UpdateInsert(collection string, cond interface{}, doc interface{}) error

func (*DbOperate) WriteGridFile

func (this *DbOperate) WriteGridFile(collection string, filename string, data []byte) error

Jump to

Keyboard shortcuts

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