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

This commit is contained in:
Rai 2022-08-27 13:40:01 -07:00
parent dbb5d02ecf
commit d63156a0d6

View file

@ -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} * @return {Attribute}
*/ */
addAttribute(type, name, value = "", isInheritable = false, position = 1000) { addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
@ -1033,10 +1040,27 @@ class Note extends AbstractEntity {
}).save(); }).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) { addLabel(name, value = "", isInheritable = false) {
return this.addAttribute(LABEL, name, value, isInheritable); 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) { addRelation(name, targetNoteId, isInheritable = false) {
return this.addAttribute(RELATION, name, targetNoteId, isInheritable); return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
} }