Documentation ¶
Index ¶
- Constants
- Variables
- func BulkInsert(db, collection string, docs ...interface{}) (*mgo.BulkResult, error)
- func BulkRemove(db, collection string, selector ...interface{}) (*mgo.BulkResult, error)
- func BulkRemoveAll(db, collection string, selector ...interface{}) (*mgo.BulkResult, error)
- func BulkUpdate(db, collection string, pairs ...interface{}) (*mgo.BulkResult, error)
- func BulkUpdateAll(db, collection string, pairs ...interface{}) (*mgo.BulkResult, error)
- func BulkUpsert(db, collection string, pairs ...interface{}) (*mgo.BulkResult, error)
- func Collection(db, collection string) (*mgo.Session, *mgo.Collection)
- func EqualError(err error, str string) bool
- func Explain(db, collection string, pipeline, result interface{}) error
- func FindAll(db, collection string, query, selector, results interface{}) error
- func FindIter(db, collection string, query interface{}) *mgo.Iter
- func FindOne(db, collection string, query, selector, result interface{}) error
- func FindPage(db, collection string, page, limit int, query, selector, results interface{}, ...) error
- func GetIncrementId(dbName, incrementName string) (int64, error)
- func GridFSCreate(db, prefix, name string) (*mgo.GridFile, error)
- func GridFSFindAll(db, prefix string, query, result interface{}) error
- func GridFSFindOne(db, prefix string, query, result interface{}) error
- func GridFSOpen(db, prefix, name string) (*mgo.GridFile, error)
- func GridFSRemove(db, prefix, name string) error
- func Insert(db, collection string, docs ...interface{}) error
- func IsExist(db, collection string, query interface{}) bool
- func PipeAll(db, collection string, pipeline, result interface{}, allowDiskUse bool) error
- func PipeIter(db, collection string, pipeline interface{}, allowDiskUse bool) *mgo.Iter
- func PipeOne(db, collection string, pipeline, result interface{}, allowDiskUse bool) error
- func RegisterMongo(url, db string) error
- func Remove(db, collection string, selector interface{}) error
- func RemoveAll(db, collection string, selector interface{}) error
- func SetIncrementDBStarId(startId int64)
- func TotalCount(db, collection string, query, selector interface{}) (int, error)
- func Update(db, collection string, selector, update interface{}, filterNull bool) error
- func UpdateAll(db, collection string, selector, data interface{}, filterNull bool) (changInfo *mgo.ChangeInfo, err error)
- type Monger
Constants ¶
View Source
const ( ErrExistConnectionDB = "exist connection db" ErrNoConnection = "no connection" ErrCannotSwitchCollection = "can not switch collection" ErrMongoObjDestroyed = "the mongo object has been destoryed" )
View Source
const (
IncrementIdsStarValue = 10000
)
Variables ¶
View Source
var (
IncrementDBStarId int64 = IncrementIdsStarValue
)
Functions ¶
func BulkInsert ¶
insert one or multi documents
func BulkRemove ¶
func BulkRemoveAll ¶
func BulkUpdate ¶
func BulkUpdateAll ¶
func BulkUpsert ¶
func Collection ¶
func Collection(db, collection string) (*mgo.Session, *mgo.Collection)
func EqualError ¶
func GetIncrementId ¶
func GridFSCreate ¶
func GridFSFindAll ¶
func GridFSFindOne ¶
func GridFSOpen ¶
func GridFSRemove ¶
func RegisterMongo ¶
RegisterMongo register a mongodb connection. alias is connection's alias url is connection url db is connection's default database name
func SetIncrementDBStarId ¶
func SetIncrementDBStarId(startId int64)
func TotalCount ¶
Types ¶
type Monger ¶
type Monger interface { IsDestroyed() bool Destroy() Use(db string) error Session() *mgo.Session CurrentDB() string Collection(c string) *mgo.Collection // CURD Insert(collection string, docs ...interface{}) (interface{}, error) Update(collection string, selector interface{}, update interface{}) error FindOne(collection string, query interface{}, result interface{}) (interface{}, error) FindAll(collection string, query interface{}, results interface{}) ([]interface{}, error) Remove(collection string, selector interface{}) error RemoveAll(collection string, selector interface{}) error }
Click to show internal directories.
Click to hide internal directories.