updated API docs

This commit is contained in:
zadam
2020-09-30 22:48:30 +02:00
parent dd020baee5
commit 4f92fbf8a5
33 changed files with 2391 additions and 2833 deletions

View File

@@ -30,16 +30,15 @@
const Entity = require('./entity');
const dateUtils = require('../services/date_utils');
const repository = require('../services/repository');
const sql = require('../services/sql');
/**
* Branch represents note's placement in the tree - it's essentially pair of noteId and parentNoteId.
* Each note can have multiple (at least one) branches, meaning it can be placed into multiple places in the tree.
*
* @property {string} branchId - primary key
* @property {string} noteId
* @property {string} parentNoteId
* @property {string} branchId - primary key, immutable
* @property {string} noteId - immutable
* @property {string} parentNoteId - immutable
* @property {int} notePosition
* @property {string} prefix
* @property {boolean} isExpanded
@@ -56,19 +55,19 @@ class Branch extends Entity {
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; }
/** @returns {Promise<Note|null>} */
async getNote() {
return await repository.getNote(this.noteId);
/** @returns {Note|null} */
getNote() {
return this.repository.getNote(this.noteId);
}
/** @returns {Promise<Note|null>} */
async getParentNote() {
return await repository.getNote(this.parentNoteId);
/** @returns {Note|null} */
getParentNote() {
return this.repository.getNote(this.parentNoteId);
}
async beforeSaving() {
beforeSaving() {
if (this.notePosition === undefined) {
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10;
}
@@ -105,7 +104,8 @@ class Branch extends Entity {
}
}
module.exports = Branch;</code></pre>
module.exports = Branch;
</code></pre>
</article>
</section>
@@ -121,7 +121,7 @@ module.exports = Branch;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>