#126, added skeleton of note relations, copied from similar concept of labels

This commit is contained in:
azivner
2018-07-27 10:52:48 +02:00
parent 4d6eda8fe6
commit 8a95afd756
15 changed files with 662 additions and 129 deletions

View File

@@ -33,6 +33,9 @@ async function updateEntity(sync, entity, sourceId) {
else if (entityName === 'labels') {
await updateLabel(entity, sourceId);
}
else if (entityName === 'relations') {
await updateRelation(entity, sourceId);
}
else if (entityName === 'api_tokens') {
await updateApiToken(entity, sourceId);
}
@@ -185,6 +188,20 @@ async function updateLabel(entity, sourceId) {
}
}
async function updateRelation(entity, sourceId) {
const origRelation = await sql.getRow("SELECT * FROM relations WHERE relationId = ?", [entity.relationId]);
if (!origRelation || origRelation.dateModified <= entity.dateModified) {
await sql.transactional(async () => {
await sql.replace("relations", entity);
await syncTableService.addRelationSync(entity.relationId, sourceId);
});
log.info("Update/sync relation " + entity.relationId);
}
}
async function updateApiToken(entity, sourceId) {
const apiTokenId = await sql.getRow("SELECT * FROM api_tokens WHERE apiTokenId = ?", [entity.apiTokenId]);