Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added some consistency checks for links and attributes
azivner6749cbed1b46
diff --git a/docs/backend_api/ApiToken.html b/docs/backend_api/ApiToken.htmlindex a0c9867ef6..ad49fa01da 100644--- a/docs/backend_api/ApiToken.html+++ b/docs/backend_api/ApiToken.html@@ -288,7 +288,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.htmlindex 841556a23d..e075fe18ea 100644--- a/docs/backend_api/Attribute.html+++ b/docs/backend_api/Attribute.html@@ -730,7 +730,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.htmlindex fd7cc35f38..8bbf93376f 100644--- a/docs/backend_api/BackendScriptApi.html+++ b/docs/backend_api/BackendScriptApi.html@@ -3814,7 +3814,7 @@ transactional by default.<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.htmlindex 0fb9512b4b..f7c46bc1fd 100644--- a/docs/backend_api/Branch.html+++ b/docs/backend_api/Branch.html@@ -511,7 +511,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Entity.html b/docs/backend_api/Entity.htmlindex 5738a6d65f..ad3cb38164 100644--- a/docs/backend_api/Entity.html+++ b/docs/backend_api/Entity.html@@ -216,7 +216,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Link.html b/docs/backend_api/Link.htmlindex 2247f9bfea..ba8ea14477 100644--- a/docs/backend_api/Link.html+++ b/docs/backend_api/Link.html@@ -358,7 +358,7 @@ this is different concept than attribute/relation.</div><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.htmlindex 4485855292..3d317b55d3 100644--- a/docs/backend_api/Note.html+++ b/docs/backend_api/Note.html@@ -446,7 +446,7 @@<div class="description">- Finds notes with given attribute name and value. Only own attributes are considered, not inherited ones+ Finds child notes with given attribute name and value. Only own attributes are considered, not inherited ones</div>@@ -1622,7 +1622,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line520">line 520</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line531">line 531</a></li></ul></dd>@@ -1722,7 +1722,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line548">line 548</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line559">line 559</a></li></ul></dd>@@ -1826,7 +1826,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line534">line 534</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line545">line 545</a></li></ul></dd>@@ -2525,6 +2525,10 @@+<div class="description">+ Get list of links coming out of this note.+</div>+@@ -2566,7 +2570,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line504">line 504</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line506">line 506</a></li></ul></dd>@@ -2670,7 +2674,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line513">line 513</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line524">line 524</a></li></ul></dd>@@ -2874,7 +2878,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line560">line 560</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line571">line 571</a></li></ul></dd>@@ -3930,6 +3934,110 @@+ <h4 class="name" id="getTargetLinks"><span class="type-signature">(async) </span>getTargetLinks<span class="signature">()</span><span class="type-signature"> → {Promise.<Array.<<a href="Link.html">Link</a>>>}</span></h4>+++++++<div class="description">+ Get list of links targetting this note.+</div>++++++++++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line515">line 515</a>+ </li></ul></dd>++++++++</dl>++++++++++++++<h5>Returns:</h5>+++++<dl>+ <dt>+ Type+ </dt>+ <dd>++<span class="param-type">Promise.<Array.<<a href="Link.html">Link</a>>></span>+++ </dd>+</dl>+++++++++++++<h4 class="name" id="getTargetRelations"><span class="type-signature">(async) </span>getTargetRelations<span class="signature">()</span><span class="type-signature"> → {Promise.<Array.<<a href="Attribute.html">Attribute</a>>>}</span></h4>@@ -4258,7 +4366,7 @@<dt class="tag-source">Source:</dt><dd class="tag-source"><ul class="dummy"><li>- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line527">line 527</a>+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line538">line 538</a></li></ul></dd>@@ -7189,7 +7297,7 @@ Cache is note instance scoped.<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.htmlindex 87fdf35ae2..b3a85b60eb 100644--- a/docs/backend_api/NoteRevision.html+++ b/docs/backend_api/NoteRevision.html@@ -403,7 +403,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.htmlindex 155eb46dc4..5f576da93b 100644--- a/docs/backend_api/Option.html+++ b/docs/backend_api/Option.html@@ -311,7 +311,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.htmlindex fa9e3e9d75..d6817f6449 100644--- a/docs/backend_api/RecentNote.html+++ b/docs/backend_api/RecentNote.html@@ -288,7 +288,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_api_token.js.html b/docs/backend_api/entities_api_token.js.htmlindex a123fcaccd..86960d717c 100644--- a/docs/backend_api/entities_api_token.js.html+++ b/docs/backend_api/entities_api_token.js.html@@ -75,7 +75,7 @@ module.exports = ApiToken;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_attribute.js.html b/docs/backend_api/entities_attribute.js.htmlindex 10ed9ffbfb..daac1dad68 100644--- a/docs/backend_api/entities_attribute.js.html+++ b/docs/backend_api/entities_attribute.js.html@@ -151,7 +151,7 @@ module.exports = Attribute;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_branch.js.html b/docs/backend_api/entities_branch.js.htmlindex da5323629c..8cf66b4c0c 100644--- a/docs/backend_api/entities_branch.js.html+++ b/docs/backend_api/entities_branch.js.html@@ -105,7 +105,7 @@ module.exports = Branch;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_entity.js.html b/docs/backend_api/entities_entity.js.htmlindex e02c82614c..06edebc13a 100644--- a/docs/backend_api/entities_entity.js.html+++ b/docs/backend_api/entities_entity.js.html@@ -93,7 +93,7 @@ module.exports = Entity;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_link.js.html b/docs/backend_api/entities_link.js.htmlindex 2912ef6665..537f962bcd 100644--- a/docs/backend_api/entities_link.js.html+++ b/docs/backend_api/entities_link.js.html@@ -92,7 +92,7 @@ module.exports = Link;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.htmlindex b2ff9f0de1..1aa0d8f180 100644--- a/docs/backend_api/entities_note.js.html+++ b/docs/backend_api/entities_note.js.html@@ -461,7 +461,7 @@ class Note extends Entity {}/**- * Finds notes with given attribute name and value. Only own attributes are considered, not inherited ones+ * Finds child notes with given attribute name and value. Only own attributes are considered, not inherited ones** @param {string} type - attribute type (label, relation, etc.)* @param {string} name - attribute name@@ -527,12 +527,23 @@ class Note extends Entity {}/**+ * Get list of links coming out of this note.+ ** @returns {Promise<Link[]>}*/async getLinks() {return await repository.getEntities("SELECT * FROM links WHERE noteId = ? AND isDeleted = 0", [this.noteId]);}+ /**+ * Get list of links targetting this note.+ *+ * @returns {Promise<Link[]>}+ */+ async getTargetLinks() {+ return await repository.getEntities("SELECT * FROM links WHERE targetNoteId = ? AND isDeleted = 0", [this.noteId]);+ }+/*** Return all links from this note, including deleted ones.*@@ -640,7 +651,7 @@ module.exports = Note;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_note_revision.js.html b/docs/backend_api/entities_note_revision.js.htmlindex 6b9c5de297..5a189c910c 100644--- a/docs/backend_api/entities_note_revision.js.html+++ b/docs/backend_api/entities_note_revision.js.html@@ -91,7 +91,7 @@ module.exports = NoteRevision;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_option.js.html b/docs/backend_api/entities_option.js.htmlindex 06d3c5f022..f49b4fdec3 100644--- a/docs/backend_api/entities_option.js.html+++ b/docs/backend_api/entities_option.js.html@@ -78,7 +78,7 @@ module.exports = Option;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/entities_recent_note.js.html b/docs/backend_api/entities_recent_note.js.htmlindex 289d64f84d..590e605f11 100644--- a/docs/backend_api/entities_recent_note.js.html+++ b/docs/backend_api/entities_recent_note.js.html@@ -75,7 +75,7 @@ module.exports = RecentNote;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/global.html b/docs/backend_api/global.htmlindex 00a68a5635..bc6e010d92 100644--- a/docs/backend_api/global.html+++ b/docs/backend_api/global.html@@ -594,7 +594,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/index.html b/docs/backend_api/index.htmlindex 8197f413b0..57a93ce408 100644--- a/docs/backend_api/index.html+++ b/docs/backend_api/index.html@@ -56,7 +56,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.htmlindex c9ac8a9d31..c6668d50d4 100644--- a/docs/backend_api/services_backend_script_api.js.html+++ b/docs/backend_api/services_backend_script_api.js.html@@ -278,7 +278,7 @@ module.exports = BackendScriptApi;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:03 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:27 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.htmlindex 8f2470bf98..ef8f37619d 100644--- a/docs/frontend_api/Branch.html+++ b/docs/frontend_api/Branch.html@@ -719,7 +719,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.htmlindex d198bb54d4..406e402658 100644--- a/docs/frontend_api/FrontendScriptApi.html+++ b/docs/frontend_api/FrontendScriptApi.html@@ -2846,7 +2846,7 @@ Internally this serializes the anonymous function into string and sends it to ba<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/NoteFull.html b/docs/frontend_api/NoteFull.htmlindex 7a49c7a15a..e94c9b77e5 100644--- a/docs/frontend_api/NoteFull.html+++ b/docs/frontend_api/NoteFull.html@@ -279,7 +279,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.htmlindex df0266233c..f3df69275f 100644--- a/docs/frontend_api/NoteShort.html+++ b/docs/frontend_api/NoteShort.html@@ -1316,7 +1316,7 @@ Its notable omission is the note content.</div><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.htmlindex c9d5338a98..76f7c6cabe 100644--- a/docs/frontend_api/entities_branch.js.html+++ b/docs/frontend_api/entities_branch.js.html@@ -76,7 +76,7 @@ export default Branch;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/entities_note_full.js.html b/docs/frontend_api/entities_note_full.js.htmlindex 93312d6c0d..eaa1721260 100644--- a/docs/frontend_api/entities_note_full.js.html+++ b/docs/frontend_api/entities_note_full.js.html@@ -64,7 +64,7 @@ export default NoteFull;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.htmlindex 9b56f110ea..52416705e9 100644--- a/docs/frontend_api/entities_note_short.js.html+++ b/docs/frontend_api/entities_note_short.js.html@@ -128,7 +128,7 @@ export default NoteShort;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.htmlindex 901fbe5153..5fb3fa8122 100644--- a/docs/frontend_api/global.html+++ b/docs/frontend_api/global.html@@ -339,7 +339,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.htmlindex 9ba1bcdba5..c576bce34b 100644--- a/docs/frontend_api/index.html+++ b/docs/frontend_api/index.html@@ -56,7 +56,7 @@<br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.htmlindex 5c5517160a..cd9c6f0fed 100644--- a/docs/frontend_api/services_frontend_script_api.js.html+++ b/docs/frontend_api/services_frontend_script_api.js.html@@ -271,7 +271,7 @@ export default FrontendScriptApi;</code></pre><br class="clear"><footer>- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Nov 13 2018 12:12:04 GMT+0100 (Central European Standard Time)+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 15 2018 13:33:28 GMT+0100 (Central European Standard Time)</footer><script> prettyPrint(); </script>diff --git a/src/entities/note.js b/src/entities/note.jsindex 4c9aaa6a50..d389ce93ee 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -499,12 +499,23 @@ class Note extends Entity {}/**+ * Get list of links coming out of this note.+ ** @returns {Promise<Link[]>}*/async getLinks() {return await repository.getEntities("SELECT * FROM links WHERE noteId = ? AND isDeleted = 0", [this.noteId]);}+ /**+ * Get list of links targetting this note.+ *+ * @returns {Promise<Link[]>}+ */+ async getTargetLinks() {+ return await repository.getEntities("SELECT * FROM links WHERE targetNoteId = ? AND isDeleted = 0", [this.noteId]);+ }+/*** Return all links from this note, including deleted ones.*diff --git a/src/services/app_info.js b/src/services/app_info.jsindex 76d2ab4a35..3b75b3d802 100644--- a/src/services/app_info.js+++ b/src/services/app_info.js@@ -3,7 +3,7 @@const build = require('./build');const packageJson = require('../../package');-const APP_DB_VERSION = 115;+const APP_DB_VERSION = 116;const SYNC_VERSION = 2;module.exports = {diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.jsindex 10ef57d998..a6045ef844 100644--- a/src/services/consistency_checks.js+++ b/src/services/consistency_checks.js@@ -219,6 +219,65 @@ async function runAllChecks() {type == 'search'`,"Search note has children", errorList);+ await fixEmptyRelationTargets(errorList);++ await runCheck(`+ SELECT+ attributeId+ FROM+ attributes+ WHERE+ type != 'label'+ AND type != 'label-definition'+ AND type != 'relation'+ AND type != 'relation-definition'`,+ "Attribute has invalid type", errorList);++ await runCheck(`+ SELECT+ attributeId+ FROM+ attributes+ LEFT JOIN notes ON attributes.noteId = notes.noteId AND notes.isDeleted = 0+ WHERE+ attributes.isDeleted = 0+ AND notes.noteId IS NULL`,+ "Attribute reference to the owning note is broken", errorList);++ await runCheck(`+ SELECT+ attributeId+ FROM+ attributes+ LEFT JOIN notes AS targetNote ON attributes.value = targetNote.noteId AND targetNote.isDeleted = 0+ WHERE+ attributes.type = 'relation'+ AND attributes.isDeleted = 0+ AND targetNote.noteId IS NULL`,+ "Relation reference to the target note is broken", errorList);++ await runCheck(`+ SELECT+ linkId+ FROM+ links+ WHERE+ type != 'image'+ AND type != 'hyper'`,+ "Link type is invalid", errorList);++ await runCheck(`+ SELECT+ linkId+ FROM+ links+ LEFT JOIN notes AS sourceNote ON sourceNote.noteId = links.noteId AND sourceNote.isDeleted = 0+ LEFT JOIN notes AS targetNote ON targetNote.noteId = links.noteId AND targetNote.isDeleted = 0+ WHERE+ sourceNote.noteId IS NULL+ OR targetNote.noteId IS NULL`,+ "Link to source/target note link is broken", errorList);+await runSyncRowChecks("notes", "noteId", errorList);await runSyncRowChecks("note_revisions", "noteRevisionId", errorList);await runSyncRowChecks("branches", "branchId", errorList);@@ -233,8 +292,6 @@ async function runAllChecks() {await checkTreeCycles(errorList);}- await fixEmptyRelationTargets(errorList);-return errorList;}diff --git a/src/services/notes.js b/src/services/notes.jsindex 08eb35e1d5..efbe27d6f6 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -332,9 +332,19 @@ async function deleteNote(branch) {await attribute.save();}- for (const attribute of await note.getTargetRelations()) {- attribute.isDeleted = true;- await attribute.save();+ for (const relation of await note.getTargetRelations()) {+ relation.isDeleted = true;+ await relation.save();+ }++ for (const link of await note.getLinks()) {+ link.isDeleted = true;+ await link.save();+ }++ for (const link of await note.getTargetLinks()) {+ link.isDeleted = true;+ await link.save();}}}