历史记录回滚时强制保存当前为历史记录

This commit is contained in:
life
2015-12-04 18:23:17 +08:00
parent 628ce118fc
commit 512ec39a16
3 changed files with 38 additions and 13 deletions

11
node_modules/note.js generated vendored
View File

@@ -208,10 +208,11 @@ var Note = {
Histories []EachHistory `Histories`
}
*/
addNoteHistory: function(noteId, content) {
addNoteHistory: function(noteId, content, callback) {
var me = this;
db.noteHistories.loadDB(function (ok) {
if (!ok) {
callback && callback(false);
return;
}
// 先判断是否存在, 不存在则新建之
@@ -219,7 +220,9 @@ var Note = {
var now = new Date();
// 新建之
if(!history) {
db.noteHistories.insert({_id: noteId, Histories: [{Content: content, "UpdatedTime": now}], "UpdatedTime": now});
db.noteHistories.insert({_id: noteId, Histories: [{Content: content, "UpdatedTime": now}], "UpdatedTime": now}, function () {
callback && callback(true);
});
}
// 更新之
else {
@@ -235,7 +238,9 @@ var Note = {
}
}
db.noteHistories.update({_id: noteId}, {$set: {Histories: histories}});
db.noteHistories.update({_id: noteId}, {$set: {Histories: histories}}, function () {
callback && callback(true);
});
}
});
});