mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
redesign of createNote APIs, WIP
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user