本文整理汇总了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;未经允许,请勿转载。 |
请发表评论