删除笔记时, 删除历史记录

This commit is contained in:
life
2015-11-15 12:15:26 +08:00
parent 3d3da50c6a
commit f518a903e7

12
node_modules/note.js generated vendored
View File

@@ -222,6 +222,12 @@ var Note = {
}); });
}); });
}, },
// 删除笔记时, 删除历史记录
deleteNoteHistory: function (noteId) {
db.noteHistories.remove({_id: noteId});
},
// 获取笔记历史记录 // 获取笔记历史记录
getNoteHistories: function(noteId, callback) { getNoteHistories: function(noteId, callback) {
var me = this; var me = this;
@@ -379,6 +385,8 @@ var Note = {
// TODO 删除附件 // TODO 删除附件
db.notes.update({_id: note._id}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) { db.notes.update({_id: note._id}, {$set: {IsDirty: true, LocalIsDelete: true}}, function(err, n) {
if(n) { if(n) {
// 删除历史记录
me.deleteNoteHistory(note.NoteId);
// 如果有tags, 则重新更新tags' count // 如果有tags, 则重新更新tags' count
me.updateTagCount(note.Tags); me.updateTagCount(note.Tags);
callback(true); callback(true);
@@ -691,9 +699,11 @@ var Note = {
} }
db.notes.remove({_id: note._id}, function(err, n) { db.notes.remove({_id: note._id}, function(err, n) {
if(err) { if(err) {
callback && callback(false); callback && callback(false);
} else { } else {
// 删除历史记录
me.deleteNoteHistory(noteId);
Notebook.reCountNotebookNumberNotes(note.NotebookId); Notebook.reCountNotebookNumberNotes(note.NotebookId);
callback && callback(true); callback && callback(true);
} }