mongo

package
v0.0.0-...-2083224 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(collection *mgo.Collection, q interface{}) int

func Delete

func Delete(collection *mgo.Collection, q interface{}) bool

删除一条

func DeleteAll

func DeleteAll(collection *mgo.Collection, q interface{}) bool

func DeleteAllByIdAndUserId

func DeleteAllByIdAndUserId(collection *mgo.Collection, id, userId string) bool

删除所有

func DeleteAllByIdAndUserId2

func DeleteAllByIdAndUserId2(collection *mgo.Collection, id, userId bson.ObjectId) bool

func DeleteByIdAndUserId

func DeleteByIdAndUserId(collection *mgo.Collection, id, userId string) bool

func DeleteByIdAndUserId2

func DeleteByIdAndUserId2(collection *mgo.Collection, id, userId bson.ObjectId) bool

func Distinct

func Distinct(collection *mgo.Collection, q bson.M, field string, i interface{})

按field去重

func Err

func Err(err error) bool

DB处理错误

func Get

func Get(collection *mgo.Collection, id string, i interface{})

func Get2

func Get2(collection *mgo.Collection, id bson.ObjectId, i interface{})

func GetByIdAndUserId

func GetByIdAndUserId(collection *mgo.Collection, id, userId string, i interface{})

func GetByIdAndUserId2

func GetByIdAndUserId2(collection *mgo.Collection, id, userId bson.ObjectId, i interface{})

func GetByQ

func GetByQ(collection *mgo.Collection, q interface{}, i interface{})

func GetByQWithFields

func GetByQWithFields(collection *mgo.Collection, q bson.M, fields []string, i interface{})

查询某些字段, q是查询条件, fields是字段名列表

func GetIdAndUserIdBsonQ

func GetIdAndUserIdBsonQ(id, userId bson.ObjectId) bson.M

func GetIdAndUserIdQ

func GetIdAndUserIdQ(id, userId string) bson.M

得到主键和userId的复合查询条件

func Has

func Has(collection *mgo.Collection, q interface{}) bool

func Insert

func Insert(collection *mgo.Collection, i interface{}) bool

func ListByQ

func ListByQ(collection *mgo.Collection, q interface{}, i interface{})

func ListByQLimit

func ListByQLimit(collection *mgo.Collection, q interface{}, i interface{}, limit int)

func ListByQWithFields

func ListByQWithFields(collection *mgo.Collection, q bson.M, fields []string, i interface{})

查询某些字段, q是查询条件, fields是字段名列表

func Update

func Update(collection *mgo.Collection, query interface{}, i interface{}) bool

适合一条记录全部更新

func UpdateAll

func UpdateAll(collection *mgo.Collection, query interface{}, i interface{}) bool

func UpdateByIdAndUserId

func UpdateByIdAndUserId(collection *mgo.Collection, id, userId string, i interface{}) bool

func UpdateByIdAndUserId2

func UpdateByIdAndUserId2(collection *mgo.Collection, id, userId bson.ObjectId, i interface{}) bool

func UpdateByIdAndUserIdField

func UpdateByIdAndUserIdField(collection *mgo.Collection, id, userId, field string, value interface{}) bool

func UpdateByIdAndUserIdField2

func UpdateByIdAndUserIdField2(collection *mgo.Collection, id, userId bson.ObjectId, field string, value interface{}) bool

func UpdateByIdAndUserIdMap

func UpdateByIdAndUserIdMap(collection *mgo.Collection, id, userId string, v bson.M) bool

func UpdateByIdAndUserIdMap2

func UpdateByIdAndUserIdMap2(collection *mgo.Collection, id, userId bson.ObjectId, v bson.M) bool

func UpdateByQField

func UpdateByQField(collection *mgo.Collection, q interface{}, field string, value interface{}) bool

func UpdateByQI

func UpdateByQI(collection *mgo.Collection, q interface{}, v interface{}) bool

func UpdateByQMap

func UpdateByQMap(collection *mgo.Collection, q interface{}, v interface{}) bool

查询条件和值

func Upsert

func Upsert(collection *mgo.Collection, query interface{}, i interface{}) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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