當前位置: 首頁>>代碼示例>>Golang>>正文


Golang db.DeleteByIdAndUserId函數代碼示例

本文整理匯總了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
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:28,代碼來源:TrashService.go

示例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
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:32,代碼來源:TrashService.go

示例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
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:12,代碼來源:TrashService.go

示例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"
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:26,代碼來源:FileService.go

示例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
}
開發者ID:howardroark2018,項目名稱:leanote-all,代碼行數:25,代碼來源:TrashService.go

示例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
}
開發者ID:ZypcGroup,項目名稱:leanote,代碼行數:9,代碼來源:BlogService.go

示例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"
}
開發者ID:kevinhuo88888,項目名稱:leanote,代碼行數:10,代碼來源:AlbumService.go

示例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, "筆記本下有筆記"
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:9,代碼來源:NotebookService.go

示例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), ""
}
開發者ID:intZz,項目名稱:leanote,代碼行數:11,代碼來源:NotebookService.go

示例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中也要刪除
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:13,代碼來源:GroupService.go

示例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"
}
開發者ID:kevinhuo88888,項目名稱:leanote,代碼行數:18,代碼來源:FileService.go

示例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中也要刪除
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:22,代碼來源:GroupService.go

示例13: DeleteTrash

// 刪除trash
func (this *TrashService) DeleteTrash(noteId, userId string) bool {
	return db.DeleteByIdAndUserId(db.Notes, noteId, userId)
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:4,代碼來源:TrashService.go


注:本文中的github.com/leanote/leanote/app/db.DeleteByIdAndUserId函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。