mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
#126, added skeleton of note relations, copied from similar concept of labels
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user