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