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

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) {
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);
}