2017-11-17 10:50:00 +08:00
|
|
|
const sql = require('./sql');
|
|
|
|
const source_id = require('./source_id');
|
|
|
|
const utils = require('./utils');
|
|
|
|
|
|
|
|
async function addNoteSync(noteId, sourceId) {
|
|
|
|
await addEntitySync("notes", noteId, sourceId)
|
|
|
|
}
|
|
|
|
|
2017-11-19 06:17:46 +08:00
|
|
|
async function addNoteTreeSync(noteTreeId, sourceId) {
|
|
|
|
await addEntitySync("notes_tree", noteTreeId, sourceId)
|
2017-11-17 10:50:00 +08:00
|
|
|
}
|
|
|
|
|
2017-11-19 06:17:46 +08:00
|
|
|
async function addNoteReorderingSync(parentNoteTreeId, sourceId) {
|
|
|
|
await addEntitySync("notes_reordering", parentNoteTreeId, sourceId)
|
2017-11-17 10:50:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function addNoteHistorySync(noteHistoryId, sourceId) {
|
|
|
|
await addEntitySync("notes_history", noteHistoryId, sourceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function addOptionsSync(optName, sourceId) {
|
|
|
|
await addEntitySync("options", optName, sourceId);
|
|
|
|
}
|
|
|
|
|
2017-11-20 01:06:48 +08:00
|
|
|
async function addRecentNoteSync(notePath, sourceId) {
|
|
|
|
await addEntitySync("recent_notes", notePath, sourceId);
|
2017-11-17 10:50:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function addEntitySync(entityName, entityId, sourceId) {
|
|
|
|
await sql.replace("sync", {
|
|
|
|
entity_name: entityName,
|
|
|
|
entity_id: entityId,
|
|
|
|
sync_date: utils.nowTimestamp(),
|
|
|
|
source_id: sourceId || source_id.currentSourceId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
addNoteSync,
|
|
|
|
addNoteTreeSync,
|
|
|
|
addNoteReorderingSync,
|
|
|
|
addNoteHistorySync,
|
|
|
|
addOptionsSync,
|
|
|
|
addRecentNoteSync
|
|
|
|
};
|