redesign of createNote APIs, WIP

This commit is contained in:
zadam
2019-11-14 23:10:56 +01:00
parent e143becb7a
commit de02e9e889
3 changed files with 131 additions and 83 deletions

View File

@@ -472,6 +472,32 @@ class Note extends Entity {
}
}
/**
* @return {Promise<Attribute>}
*/
async createAttribute(type, name, value = "") {
const attr = new Attribute({
noteId: this.noteId,
type: type,
name: name,
value: value
});
await attr.save();
this.invalidateAttributeCache();
return attr;
}
async createLabel(name, value = "") {
return await this.createAttribute(LABEL, name, value);
}
async createRelation(name, targetNoteId) {
return await this.createAttribute(RELATION, name, targetNoteId);
}
/**
* @param {string} name - label name
* @returns {Promise<boolean>} true if label exists (including inherited)