本文整理匯總了Golang中github.com/leanote/leanote/app/db.DeleteByIdAndUserId函數的典型用法代碼示例。如果您正苦於以下問題:Golang DeleteByIdAndUserId函數的具體用法?Golang DeleteByIdAndUserId怎麽用?Golang DeleteByIdAndUserId使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DeleteByIdAndUserId函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteTrash
// 刪除trash
func (this *TrashService) DeleteTrash(noteId, userId string) bool {
note := noteService.GetNote(noteId, userId)
if note.NoteId == "" {
return false
}
// delete note's attachs
ok := attachService.DeleteAllAttachs(noteId, userId)
// 設置刪除位
ok = db.UpdateByIdAndUserIdMap(db.Notes, noteId, userId,
bson.M{"IsDeleted": true,
"Usn": userService.IncrUsn(userId)})
// delete note
// ok = db.DeleteByIdAndUserId(db.Notes, noteId, userId)
// delete content
ok = db.DeleteByIdAndUserId(db.NoteContents, noteId, userId)
// 刪除content history
ok = db.DeleteByIdAndUserId(db.NoteContentHistories, noteId, userId)
// 重新統計tag's count
// TODO 這裏會改變tag's Usn
tagService.reCountTagCount(userId, note.Tags)
return ok
}
示例2: DeleteTrashApi
func (this *TrashService) DeleteTrashApi(noteId, userId string, usn int) (bool, string, int) {
note := noteService.GetNote(noteId, userId)
if note.NoteId == "" || note.IsDeleted {
return false, "notExists", 0
}
if note.Usn != usn {
return false, "conflict", 0
}
// delete note's attachs
ok := attachService.DeleteAllAttachs(noteId, userId)
// 設置刪除位
afterUsn := userService.IncrUsn(userId)
ok = db.UpdateByIdAndUserIdMap(db.Notes, noteId, userId,
bson.M{"IsDeleted": true,
"Usn": afterUsn})
// delete content
ok = db.DeleteByIdAndUserId(db.NoteContents, noteId, userId)
// 刪除content history
ok = db.DeleteByIdAndUserId(db.NoteContentHistories, noteId, userId)
// 一個BUG, iOS刪除直接調用這個API, 結果沒有重新recount
// recount notebooks' notes number
notebookService.ReCountNotebookNumberNotes(note.NotebookId.Hex())
return ok, "", afterUsn
}
示例3: DeleteTrash
// 刪除trash
func (this *TrashService) DeleteTrash(noteId, userId string) bool {
// delete note's attachs
ok := attachService.DeleteAllAttachs(noteId, userId)
// delete note
ok = db.DeleteByIdAndUserId(db.Notes, noteId, userId)
// delete content
ok = db.DeleteByIdAndUserId(db.NoteContents, noteId, userId)
return ok
}
示例4: DeleteImage
// delete image
func (this *FileService) DeleteImage(userId, fileId string) (bool, string) {
file := info.File{}
db.GetByIdAndUserId(db.Files, fileId, userId, &file)
if file.FileId != "" {
if db.DeleteByIdAndUserId(db.Files, fileId, userId) {
// delete image
// TODO
file.Path = strings.TrimLeft(file.Path, "/")
var err error
if strings.HasPrefix(file.Path, "upload") {
Log(file.Path)
err = os.Remove(revel.BasePath + "/public/" + file.Path)
} else {
err = os.Remove(revel.BasePath + "/" + file.Path)
}
if err == nil {
return true, ""
}
return false, "delete file error!"
}
return false, "db error"
}
return false, "no such item"
}
示例5: DeleteTrashApi
func (this *TrashService) DeleteTrashApi(noteId, userId string, usn int) (bool, string, int) {
note := noteService.GetNote(noteId, userId)
if note.NoteId == "" || note.IsDeleted {
return false, "notExists", 0
}
if note.Usn != usn {
return false, "conflict", 0
}
// delete note's attachs
ok := attachService.DeleteAllAttachs(noteId, userId)
// 設置刪除位
afterUsn := userService.IncrUsn(userId)
ok = db.UpdateByIdAndUserIdMap(db.Notes, noteId, userId,
bson.M{"IsDeleted": true,
"Usn": afterUsn})
// delete content
ok = db.DeleteByIdAndUserId(db.NoteContents, noteId, userId)
return ok, "", afterUsn
}
示例6: DeleteSingle
// 刪除頁麵
func (this *BlogService) DeleteSingle(userId, singleId string) (ok bool) {
ok = db.DeleteByIdAndUserId(db.BlogSingles, singleId, userId)
if ok {
// 還要修改UserBlog中的Singles
this.updateBlogSingles(userId, true, false, singleId, "", "")
}
return
}
示例7: DeleteAlbum
// delete album
// presupposition: has no images under this ablum
func (this *AlbumService) DeleteAlbum(userId, albumId string) (bool, string) {
if db.Count(db.Files, bson.M{"AlbumId": bson.ObjectIdHex(albumId),
"UserId": bson.ObjectIdHex(userId),
}) == 0 {
return db.DeleteByIdAndUserId(db.Albums, albumId, userId), ""
}
return false, "has images"
}
示例8: DeleteNotebook
// 先查看該notebookId下是否有notes, 沒有則刪除
func (this *NotebookService) DeleteNotebook(userId, notebookId string) (bool, string) {
if db.Count(db.Notes, bson.M{"NotebookId": bson.ObjectIdHex(notebookId),
"UserId": bson.ObjectIdHex(userId),
"IsTrash": false}) == 0 { // 不包含trash
return db.DeleteByIdAndUserId(db.Notebooks, notebookId, userId), ""
}
return false, "筆記本下有筆記"
}
示例9: DeleteNotebookForce
// API調用, 刪除筆記本, 不作筆記控製
func (this *NotebookService) DeleteNotebookForce(userId, notebookId string, usn int) (bool, string) {
notebook := this.GetNotebookById(notebookId)
// 不存在
if notebook.NotebookId == "" {
return false, "notExists"
} else if notebook.Usn != usn {
return false, "conflict"
}
return db.DeleteByIdAndUserId(db.Notebooks, notebookId, userId), ""
}
示例10: DeleteGroup
// 刪除分組
// 判斷是否有好友
func (this *GroupService) DeleteGroup(userId, groupId string) (ok bool, msg string) {
/*
if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)}) {
return false, "groupHasUsers"
}
*/
db.DeleteAll(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)})
return db.DeleteByIdAndUserId(db.Groups, groupId, userId), ""
// TODO 刪除分組後, 在shareNote, shareNotebook中也要刪除
}
示例11: DeleteImage
// delete image
func (this *FileService) DeleteImage(userId, fileId string) (bool, string) {
file := info.File{}
db.GetByIdAndUserId(db.Files, fileId, userId, &file)
if file.FileId != "" {
if db.DeleteByIdAndUserId(db.Files, fileId, userId) {
// delete image
err := os.Remove(revel.BasePath + "/public/" + file.Path)
if err == nil {
return true, ""
}
return false, "delete file error!"
}
return false, "db error"
}
return false, "no such item"
}
示例12: DeleteGroup
// 刪除分組
// 判斷是否有好友
func (this *GroupService) DeleteGroup(userId, groupId string) (ok bool, msg string) {
/*
if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)}) {
return false, "groupHasUsers"
}
*/
if !this.isMyGroup(userId, groupId) {
return false, "notMyGroup"
}
// 刪除分組後, 需要刪除所有用戶分享到該組的筆記本, 筆記
shareService.DeleteAllShareNotebookGroup(groupId)
shareService.DeleteAllShareNoteGroup(groupId)
db.DeleteAll(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId)})
return db.DeleteByIdAndUserId(db.Groups, groupId, userId), ""
// TODO 刪除分組後, 在shareNote, shareNotebook中也要刪除
}
示例13: DeleteTrash
// 刪除trash
func (this *TrashService) DeleteTrash(noteId, userId string) bool {
return db.DeleteByIdAndUserId(db.Notes, noteId, userId)
}