separate DB connection for each transaction (just for the record, will be reverted probably)

This commit is contained in:
azivner
2017-11-28 17:04:47 -05:00
parent 4d95eb0762
commit fd764f6163
21 changed files with 326 additions and 429 deletions

View File

@@ -2,32 +2,32 @@ const sql = require('./sql');
const source_id = require('./source_id');
const utils = require('./utils');
async function addNoteSync(noteId, sourceId) {
await addEntitySync("notes", noteId, sourceId)
async function addNoteSync(db, noteId, sourceId) {
await addEntitySync(db, "notes", noteId, sourceId)
}
async function addNoteTreeSync(noteTreeId, sourceId) {
await addEntitySync("notes_tree", noteTreeId, sourceId)
async function addNoteTreeSync(db, noteTreeId, sourceId) {
await addEntitySync(db, "notes_tree", noteTreeId, sourceId)
}
async function addNoteReorderingSync(parentNoteTreeId, sourceId) {
await addEntitySync("notes_reordering", parentNoteTreeId, sourceId)
async function addNoteReorderingSync(db, parentNoteTreeId, sourceId) {
await addEntitySync(db, "notes_reordering", parentNoteTreeId, sourceId)
}
async function addNoteHistorySync(noteHistoryId, sourceId) {
await addEntitySync("notes_history", noteHistoryId, sourceId);
async function addNoteHistorySync(db, noteHistoryId, sourceId) {
await addEntitySync(db, "notes_history", noteHistoryId, sourceId);
}
async function addOptionsSync(optName, sourceId) {
await addEntitySync("options", optName, sourceId);
async function addOptionsSync(db, optName, sourceId) {
await addEntitySync(db, "options", optName, sourceId);
}
async function addRecentNoteSync(notePath, sourceId) {
await addEntitySync("recent_notes", notePath, sourceId);
async function addRecentNoteSync(db, notePath, sourceId) {
await addEntitySync(db, "recent_notes", notePath, sourceId);
}
async function addEntitySync(entityName, entityId, sourceId) {
await sql.replace("sync", {
async function addEntitySync(db, entityName, entityId, sourceId) {
await sql.replace(db, "sync", {
entity_name: entityName,
entity_id: entityId,
sync_date: utils.nowTimestamp(),