entities_link.js.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: entities/link.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: entities/link.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>"use strict";
  20. const Entity = require('./entity');
  21. const repository = require('../services/repository');
  22. const dateUtils = require('../services/date_utils');
  23. /**
  24. * This class represents link from one note to another in the form of hyperlink or image reference. Note that
  25. * this is different concept than attribute/relation.
  26. *
  27. * @param {string} linkId
  28. * @param {string} noteId
  29. * @param {string} targetNoteId
  30. * @param {string} type
  31. * @param {boolean} isDeleted
  32. * @param {string} utcDateModified
  33. * @param {string} utcDateCreated
  34. *
  35. * @extends Entity
  36. */
  37. class Link extends Entity {
  38. static get entityName() { return "links"; }
  39. static get primaryKeyName() { return "linkId"; }
  40. static get hashedProperties() { return ["linkId", "noteId", "targetNoteId", "type", "isDeleted", "utcDateCreated", "utcDateModified"]; }
  41. async getNote() {
  42. return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
  43. }
  44. async getTargetNote() {
  45. return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.targetNoteId]);
  46. }
  47. beforeSaving() {
  48. if (!this.isDeleted) {
  49. this.isDeleted = false;
  50. }
  51. if (!this.utcDateCreated) {
  52. this.utcDateCreated = dateUtils.utcNowDateTime();
  53. }
  54. super.beforeSaving();
  55. if (this.isChanged) {
  56. this.utcDateModified = dateUtils.utcNowDateTime();
  57. }
  58. }
  59. }
  60. module.exports = Link;</code></pre>
  61. </article>
  62. </section>
  63. </div>
  64. <nav>
  65. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="Entity.html">Entity</a></li><li><a href="Link.html">Link</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>
  66. </nav>
  67. <br class="clear">
  68. <footer>
  69. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
  70. </footer>
  71. <script> prettyPrint(); </script>
  72. <script src="scripts/linenumber.js"> </script>
  73. </body>
  74. </html>