本文整理匯總了Golang中github.com/leanote/leanote/app/db.GetByQWithFields函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetByQWithFields函數的具體用法?Golang GetByQWithFields怎麽用?Golang GetByQWithFields使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetByQWithFields函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetNotebookId
// 通過noteId得到notebookId
// shareService call
// [ok]
func (this *NoteService) GetNotebookId(noteId string) bson.ObjectId {
note := info.Note{}
// db.Get(db.Notes, noteId, ¬e)
// LogJ(note)
db.GetByQWithFields(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, []string{"NotebookId"}, ¬e)
return note.NotebookId
}
示例2: GetThemePath
func (this *ThemeService) GetThemePath(userId, themeId string) string {
theme := info.Theme{}
db.GetByQWithFields(db.Themes, bson.M{"_id": bson.ObjectIdHex(themeId), "UserId": bson.ObjectIdHex(userId)}, []string{"Path"}, &theme)
if theme.Path != "" {
return theme.Path
}
return ""
}
示例3: IncrUsn
// 自增Usn
// 每次notebook,note添加, 修改, 刪除, 都要修改
func (this *UserService) IncrUsn(userId string) int {
user := info.User{}
query := bson.M{"_id": bson.ObjectIdHex(userId)}
db.GetByQWithFields(db.Users, query, []string{"Usn"}, &user)
usn := user.Usn
usn += 1
Log("inc Usn")
db.UpdateByQField(db.Users, query, "Usn", usn)
return usn
// return db.Update(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, bson.M{"$inc": bson.M{"ReadNum": 1}})
}
示例4: IsBlog
// 判斷是否是blog
func (this *NotebookService) IsBlog(notebookId string) bool {
notebook := info.Notebook{}
db.GetByQWithFields(db.Notebooks, bson.M{"_id": bson.ObjectIdHex(notebookId)}, []string{"IsBlog"}, ¬ebook)
return notebook.IsBlog
}
示例5: GetUsername
// 得到用戶名
func (this *UserService) GetUsername(userId string) string {
user := info.User{}
db.GetByQWithFields(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, []string{"Username"}, &user)
return user.Username
}
示例6: GetUsn
func (this *UserService) GetUsn(userId string) int {
user := info.User{}
query := bson.M{"_id": bson.ObjectIdHex(userId)}
db.GetByQWithFields(db.Users, query, []string{"Usn"}, &user)
return user.Usn
}