From f518a903e7806ff88cf14d7ace2bb9d408aaf937 Mon Sep 17 00:00:00 2001 From: life Date: Sun, 15 Nov 2015 12:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=AC=94=E8=AE=B0=E6=97=B6,?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node_modules/note.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); }