basic entities for attributes (unification of labels and relations)

This commit is contained in:
azivner
2018-08-02 22:48:21 +02:00
parent 040f9185f8
commit 097114c0f2
10 changed files with 253 additions and 25 deletions

View File

@@ -30,6 +30,9 @@ async function updateEntity(sync, entity, sourceId) {
else if (entityName === 'note_images') {
await updateNoteImage(entity, sourceId);
}
else if (entityName === 'attributes') {
await updateAttribute(entity, sourceId);
}
else if (entityName === 'labels') {
await updateLabel(entity, sourceId);
}
@@ -174,6 +177,20 @@ async function updateNoteImage(entity, sourceId) {
}
}
async function updateAttribute(entity, sourceId) {
const origAttribute = await sql.getRow("SELECT * FROM attributes WHERE attributeId = ?", [entity.attributeId]);
if (!origAttribute || origAttribute.dateModified <= entity.dateModified) {
await sql.transactional(async () => {
await sql.replace("attributes", entity);
await syncTableService.addAttributeSync(entity.attributeId, sourceId);
});
log.info("Update/sync attribute " + entity.attributeId);
}
}
async function updateLabel(entity, sourceId) {
const origLabel = await sql.getRow("SELECT * FROM labels WHERE labelId = ?", [entity.labelId]);