Skip to content

Build your personal knowledge base with Trilium Notes

Add some docs to note.js (for backend scripting docs)

Raid63156a0d6b6
diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js
index 595e410522..e1ff8c2277 100644
--- a/src/becca/entities/note.js
+++ b/src/becca/entities/note.js
@@ -1018,6 +1018,13 @@ class Note extends AbstractEntity {
}
/**
+ * Adds a new attribute to this note. The attribute is saved and returned.
+ * See addLabel, addRelation for more specific methods.
+ *
+ * @param {string} type - attribute type (label / relation)
+ * @param {string} name - name of the attribute, not including the leading ~/#
+ * @param {string} [value] - value of the attribute - text for labels, target note ID for relations; optional.
+ *
* @return {Attribute}
*/
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
@@ -1033,10 +1040,27 @@ class Note extends AbstractEntity {
}).save();
}
+ /**
+ * Adds a new label to this note. The label attribute is saved and returned.
+ *
+ * @param {string} name - name of the label, not including the leading #
+ * @param {string} [value] - text value of the label; optional
+ *
+ * @return {Attribute}
+ */
addLabel(name, value = "", isInheritable = false) {
return this.addAttribute(LABEL, name, value, isInheritable);
}
+ /**
+ * Adds a new relation to this note. The relation attribute is saved and
+ * returned.
+ *
+ * @param {string} name - name of the relation, not including the leading ~
+ * @param {string} value - ID of the target note of the relation
+ *
+ * @return {Attribute}
+ */
addRelation(name, targetNoteId, isInheritable = false) {
return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
}