update to entity creates sync event

This commit is contained in:
azivner 2018-01-30 20:12:19 -05:00
parent 35c7b54176
commit 5217339209
6 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,7 @@ const Entity = require('./entity');
class Attribute extends Entity { class Attribute extends Entity {
static get tableName() { return "attributes"; } static get tableName() { return "attributes"; }
static get primaryKeyName() { return "attributeId"; }
async getNote() { async getNote() {
return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);

View File

@ -5,6 +5,7 @@ const protected_session = require('../services/protected_session');
class Note extends Entity { class Note extends Entity {
static get tableName() { return "notes"; } static get tableName() { return "notes"; }
static get primaryKeyName() { return "noteId"; }
constructor(repository, row) { constructor(repository, row) {
super(repository, row); super(repository, row);

View File

@ -4,6 +4,7 @@ const Entity = require('./entity');
class NoteRevision extends Entity { class NoteRevision extends Entity {
static get tableName() { return "note_revisions"; } static get tableName() { return "note_revisions"; }
static get primaryKeyName() { return "noteRevisionId"; }
async getNote() { async getNote() {
return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);

View File

@ -4,6 +4,7 @@ const Entity = require('./entity');
class NoteTree extends Entity { class NoteTree extends Entity {
static get tableName() { return "note_tree"; } static get tableName() { return "note_tree"; }
static get primaryKeyName() { return "noteTreeId"; }
async getNote() { async getNote() {
return this.repository.getEntity("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]); return this.repository.getEntity("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);

View File

@ -4,6 +4,7 @@ const Note = require('../entities/note');
const NoteRevision = require('../entities/note_revision'); const NoteRevision = require('../entities/note_revision');
const NoteTree = require('../entities/note_tree'); const NoteTree = require('../entities/note_tree');
const Attribute = require('../entities/attribute'); const Attribute = require('../entities/attribute');
const sync_table = require('../services/sync_table');
class Repository { class Repository {
constructor(dataKey) { constructor(dataKey) {
@ -70,6 +71,10 @@ class Repository {
delete clone.repository; delete clone.repository;
await sql.replace(entity.constructor.tableName, entity); await sql.replace(entity.constructor.tableName, entity);
const primaryKey = entity[entity.constructor.primaryKeyName];
await sync_table.addEntitySync(entity.constructor.tableName, primaryKey);
} }
} }

View File

@ -105,6 +105,7 @@ module.exports = {
addImageSync, addImageSync,
addNoteImageSync, addNoteImageSync,
addAttributeSync, addAttributeSync,
addEntitySync,
cleanupSyncRowsForMissingEntities, cleanupSyncRowsForMissingEntities,
fillAllSyncRows fillAllSyncRows
}; };