notebook, note同步

note待同步内容, 图片
This commit is contained in:
life
2015-01-22 00:41:49 +08:00
parent 1674b9f91d
commit 1d015642a6
8 changed files with 339 additions and 73 deletions

53
node_modules/note.js generated vendored
View File

@@ -117,6 +117,59 @@ var Note = {
return callback && callback(notes);
});
},
// 得到笔记
getNote: function(noteId, callback) {
var me = this;
Notes.findOne({NoteId: noteId}, function(err, doc) {
if(err || !doc) {
log('不存在');
callback && callback(false);
} else {
callback && callback(doc);
}
});
},
//----------------
// 同步
//----------------
// 强制删除
deleteNoteForce: function(noteId, callback) {
var me = this;
Notes.remove({NoteId: noteId}, function(err, n) {
if(err) {
callback && callback(false);
} else {
callback && callback(true);
}
});
},
// 添加笔记本, note object
addNoteForce: function(note, callback) {
note.InitSync = true; // 刚同步完, 表示content, images, attach没有同步
Notes.insert(note, function (err, newDoc) { // Callback is optional
if(err) {
console.log(err);
callback && callback(false);
} else {
callback && callback(newDoc);
}
});
},
// 更新笔记本
updateNoteForce: function(note, callback) {
note.IsDirty = false;
Notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, updates) { // Callback is optional
if(err) {
console.log(err);
callback && callback(false);
} else {
callback && callback(note);
}
});
},
};
module.exports = Note;