mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
add missing doc pages
This commit is contained in:
parent
534c71491b
commit
d1b3d8a58a
432
docs/backend_api/AbstractEntity.html
Normal file
432
docs/backend_api/AbstractEntity.html
Normal file
@ -0,0 +1,432 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>JSDoc: Class: AbstractEntity</title>
|
||||||
|
|
||||||
|
<script src="scripts/prettify/prettify.js"> </script>
|
||||||
|
<script src="scripts/prettify/lang-css.js"> </script>
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">Class: AbstractEntity</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2><span class="attribs"><span class="type-signature"></span></span>AbstractEntity<span class="signature">()</span><span class="type-signature"></span></h2>
|
||||||
|
|
||||||
|
<div class="class-description">Base class for all backend entities.</div>
|
||||||
|
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<div class="container-overview">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Constructor</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="AbstractEntity"><span class="type-signature"></span>new AbstractEntity<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="becca_entities_abstract_entity.js.html">becca/entities/abstract_entity.js</a>, <a href="becca_entities_abstract_entity.js.html#line16">line 16</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3 class="subsection-title">Methods</h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="markAsDeleted"><span class="type-signature"></span>markAsDeleted<span class="signature">(deleteId<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
Mark the entity as (soft) deleted. It will be completely erased later.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Attributes</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>Default</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>deleteId</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="attributes">
|
||||||
|
|
||||||
|
<optional><br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="default">
|
||||||
|
|
||||||
|
null
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="becca_entities_abstract_entity.js.html">becca/entities/abstract_entity.js</a>, <a href="becca_entities_abstract_entity.js.html#line116">line 116</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="save"><span class="type-signature"></span>save<span class="signature">()</span><span class="type-signature"> → {<a href="AbstractEntity.html">AbstractEntity</a>}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
Saves entity - executes SQL, but doesn't commit the transaction on its own
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="becca_entities_abstract_entity.js.html">becca/entities/abstract_entity.js</a>, <a href="becca_entities_abstract_entity.js.html#line73">line 73</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type"><a href="AbstractEntity.html">AbstractEntity</a></span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="AbstractEntity.html">AbstractEntity</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="EtapiToken.html">EtapiToken</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>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script> prettyPrint(); </script>
|
||||||
|
<script src="scripts/linenumber.js"> </script>
|
||||||
|
</body>
|
||||||
|
</html>
|
209
docs/backend_api/becca_entities_abstract_entity.js.html
Normal file
209
docs/backend_api/becca_entities_abstract_entity.js.html
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>JSDoc: Source: becca/entities/abstract_entity.js</title>
|
||||||
|
|
||||||
|
<script src="scripts/prettify/prettify.js"> </script>
|
||||||
|
<script src="scripts/prettify/lang-css.js"> </script>
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">Source: becca/entities/abstract_entity.js</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<article>
|
||||||
|
<pre class="prettyprint source linenums"><code>"use strict";
|
||||||
|
|
||||||
|
const utils = require('../../services/utils');
|
||||||
|
const sql = require('../../services/sql');
|
||||||
|
const entityChangesService = require('../../services/entity_changes');
|
||||||
|
const eventService = require("../../services/events");
|
||||||
|
const dateUtils = require("../../services/date_utils");
|
||||||
|
const cls = require("../../services/cls");
|
||||||
|
const log = require("../../services/log");
|
||||||
|
|
||||||
|
let becca = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for all backend entities.
|
||||||
|
*/
|
||||||
|
class AbstractEntity {
|
||||||
|
beforeSaving() {
|
||||||
|
this.generateIdIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
|
generateIdIfNecessary() {
|
||||||
|
if (!this[this.constructor.primaryKeyName]) {
|
||||||
|
this[this.constructor.primaryKeyName] = utils.newEntityId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generateHash(isDeleted = false) {
|
||||||
|
let contentToHash = "";
|
||||||
|
|
||||||
|
for (const propertyName of this.constructor.hashedProperties) {
|
||||||
|
contentToHash += "|" + this[propertyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDeleted) {
|
||||||
|
contentToHash += "|deleted";
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.hash(contentToHash).substr(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
getUtcDateChanged() {
|
||||||
|
return this.utcDateModified || this.utcDateCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
get becca() {
|
||||||
|
if (!becca) {
|
||||||
|
becca = require('../becca');
|
||||||
|
}
|
||||||
|
|
||||||
|
return becca;
|
||||||
|
}
|
||||||
|
|
||||||
|
addEntityChange(isDeleted = false) {
|
||||||
|
entityChangesService.addEntityChange({
|
||||||
|
entityName: this.constructor.entityName,
|
||||||
|
entityId: this[this.constructor.primaryKeyName],
|
||||||
|
hash: this.generateHash(isDeleted),
|
||||||
|
isErased: false,
|
||||||
|
utcDateChanged: this.getUtcDateChanged(),
|
||||||
|
isSynced: this.constructor.entityName !== 'options' || !!this.isSynced
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPojoToSave() {
|
||||||
|
return this.getPojo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves entity - executes SQL, but doesn't commit the transaction on its own
|
||||||
|
*
|
||||||
|
* @returns {AbstractEntity}
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
const entityName = this.constructor.entityName;
|
||||||
|
const primaryKeyName = this.constructor.primaryKeyName;
|
||||||
|
|
||||||
|
const isNewEntity = !this[primaryKeyName];
|
||||||
|
|
||||||
|
if (this.beforeSaving) {
|
||||||
|
this.beforeSaving();
|
||||||
|
}
|
||||||
|
|
||||||
|
const pojo = this.getPojoToSave();
|
||||||
|
|
||||||
|
sql.transactional(() => {
|
||||||
|
sql.upsert(entityName, primaryKeyName, pojo);
|
||||||
|
|
||||||
|
if (entityName === 'recent_notes') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addEntityChange(false);
|
||||||
|
|
||||||
|
if (!cls.isEntityEventsDisabled()) {
|
||||||
|
const eventPayload = {
|
||||||
|
entityName,
|
||||||
|
entity: this
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isNewEntity) {
|
||||||
|
eventService.emit(eventService.ENTITY_CREATED, eventPayload);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventService.emit(eventService.ENTITY_CHANGED, eventPayload);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the entity as (soft) deleted. It will be completely erased later.
|
||||||
|
*
|
||||||
|
* @param [deleteId=null]
|
||||||
|
*/
|
||||||
|
markAsDeleted(deleteId = null) {
|
||||||
|
const entityId = this[this.constructor.primaryKeyName];
|
||||||
|
const entityName = this.constructor.entityName;
|
||||||
|
|
||||||
|
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||||
|
|
||||||
|
sql.execute(`UPDATE ${entityName} SET isDeleted = 1, deleteId = ?, utcDateModified = ?
|
||||||
|
WHERE ${this.constructor.primaryKeyName} = ?`,
|
||||||
|
[deleteId, this.utcDateModified, entityId]);
|
||||||
|
|
||||||
|
if (this.dateModified) {
|
||||||
|
this.dateModified = dateUtils.localNowDateTime();
|
||||||
|
|
||||||
|
sql.execute(`UPDATE ${entityName} SET dateModified = ? WHERE ${this.constructor.primaryKeyName} = ?`,
|
||||||
|
[this.dateModified, entityId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(`Marking ${entityName} ${entityId} as deleted`);
|
||||||
|
|
||||||
|
this.addEntityChange(true);
|
||||||
|
|
||||||
|
eventService.emit(eventService.ENTITY_DELETED, { entityName, entityId, entity: this });
|
||||||
|
}
|
||||||
|
|
||||||
|
markAsDeletedSimple() {
|
||||||
|
const entityId = this[this.constructor.primaryKeyName];
|
||||||
|
const entityName = this.constructor.entityName;
|
||||||
|
|
||||||
|
this.utcDateModified = dateUtils.utcNowDateTime();
|
||||||
|
|
||||||
|
sql.execute(`UPDATE ${entityName} SET isDeleted = 1, utcDateModified = ?
|
||||||
|
WHERE ${this.constructor.primaryKeyName} = ?`,
|
||||||
|
[this.utcDateModified, entityId]);
|
||||||
|
|
||||||
|
log.info(`Marking ${entityName} ${entityId} as deleted`);
|
||||||
|
|
||||||
|
this.addEntityChange(true);
|
||||||
|
|
||||||
|
eventService.emit(eventService.ENTITY_DELETED, { entityName, entityId, entity: this });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = AbstractEntity;
|
||||||
|
</code></pre>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="AbstractEntity.html">AbstractEntity</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="EtapiToken.html">EtapiToken</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>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script> prettyPrint(); </script>
|
||||||
|
<script src="scripts/linenumber.js"> </script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user