diff --git a/src/entities/attribute.js b/src/entities/attribute.js index 022b344a7..a82a00216 100644 --- a/src/entities/attribute.js +++ b/src/entities/attribute.js @@ -4,6 +4,7 @@ const Entity = require('./entity'); class Attribute extends Entity { static get tableName() { return "attributes"; } + static get primaryKeyName() { return "attributeId"; } async getNote() { return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); diff --git a/src/entities/note.js b/src/entities/note.js index 661b9e3e7..fe04defaa 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -5,6 +5,7 @@ const protected_session = require('../services/protected_session'); class Note extends Entity { static get tableName() { return "notes"; } + static get primaryKeyName() { return "noteId"; } constructor(repository, row) { super(repository, row); diff --git a/src/entities/note_revision.js b/src/entities/note_revision.js index 09a888d48..1d140f593 100644 --- a/src/entities/note_revision.js +++ b/src/entities/note_revision.js @@ -4,6 +4,7 @@ const Entity = require('./entity'); class NoteRevision extends Entity { static get tableName() { return "note_revisions"; } + static get primaryKeyName() { return "noteRevisionId"; } async getNote() { return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); diff --git a/src/entities/note_tree.js b/src/entities/note_tree.js index 7bdce0b4c..2f73b7fd8 100644 --- a/src/entities/note_tree.js +++ b/src/entities/note_tree.js @@ -4,6 +4,7 @@ const Entity = require('./entity'); class NoteTree extends Entity { static get tableName() { return "note_tree"; } + static get primaryKeyName() { return "noteTreeId"; } async getNote() { return this.repository.getEntity("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]); diff --git a/src/services/repository.js b/src/services/repository.js index 829ea7cdd..9392a4a1b 100644 --- a/src/services/repository.js +++ b/src/services/repository.js @@ -4,6 +4,7 @@ const Note = require('../entities/note'); const NoteRevision = require('../entities/note_revision'); const NoteTree = require('../entities/note_tree'); const Attribute = require('../entities/attribute'); +const sync_table = require('../services/sync_table'); class Repository { constructor(dataKey) { @@ -70,6 +71,10 @@ class Repository { delete clone.repository; await sql.replace(entity.constructor.tableName, entity); + + const primaryKey = entity[entity.constructor.primaryKeyName]; + + await sync_table.addEntitySync(entity.constructor.tableName, primaryKey); } } diff --git a/src/services/sync_table.js b/src/services/sync_table.js index 45cf5b9b2..412f7aa77 100644 --- a/src/services/sync_table.js +++ b/src/services/sync_table.js @@ -105,6 +105,7 @@ module.exports = { addImageSync, addNoteImageSync, addAttributeSync, + addEntitySync, cleanupSyncRowsForMissingEntities, fillAllSyncRows }; \ No newline at end of file