db

package
Version: v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: GPL-2.0, GPL-2.0-or-later Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Albums *mgo.Collection

Album & file(image)

View Source
var Attachs *mgo.Collection
View Source
var BlogComments *mgo.Collection
View Source
var BlogLikes *mgo.Collection

blog

View Source
var BlogSingles *mgo.Collection
View Source
var Configs *mgo.Collection
View Source
var EmailLogs *mgo.Collection
View Source
var GroupUsers *mgo.Collection
View Source
var Groups *mgo.Collection
View Source
var HasShareNotes *mgo.Collection
View Source
var NoteContentHistories *mgo.Collection
View Source
var NoteContents *mgo.Collection
View Source
var NoteImages *mgo.Collection
View Source
var NoteTags *mgo.Collection
View Source
var Notebooks *mgo.Collection

各个表的Collection对象

View Source
var Reports *mgo.Collection
View Source
var Session *mgo.Session

数据连接

View Source
var Sessions *mgo.Collection

session

View Source
var ShareNotebooks *mgo.Collection
View Source
var ShareNotes *mgo.Collection
View Source
var Suggestions *mgo.Collection
View Source
var TagCounts *mgo.Collection
View Source
var Themes *mgo.Collection
View Source
var Tokens *mgo.Collection
View Source
var UserBlogs *mgo.Collection

Functions

func CheckMongoSessionLost

func CheckMongoSessionLost()

检查mognodb是否lost connection 每个请求之前都要检查!!

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 Init

func Init(url, dbname string)

初始化时连接数据库

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.

Source Files

Jump to

Keyboard shortcuts

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