mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 16:55:50 +01:00
optimized becca loader with raw queries
This commit is contained in:
@@ -20,8 +20,61 @@ class Note extends AbstractEntity {
|
||||
constructor(row) {
|
||||
super();
|
||||
|
||||
this.update(row);
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.update([
|
||||
row.noteId,
|
||||
row.title,
|
||||
row.type,
|
||||
row.mime,
|
||||
row.isProtected,
|
||||
row.dateCreated,
|
||||
row.dateModified,
|
||||
row.utcDateCreated,
|
||||
row.utcDateModified
|
||||
]);
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
update([noteId, title, type, mime, isProtected, dateCreated, dateModified, utcDateCreated, utcDateModified]) {
|
||||
// ------ Database persisted attributes ------
|
||||
|
||||
/** @param {string} */
|
||||
this.noteId = noteId;
|
||||
/** @param {string} */
|
||||
this.title = title;
|
||||
/** @param {boolean} */
|
||||
this.isProtected = !!isProtected;
|
||||
/** @param {string} */
|
||||
this.type = type;
|
||||
/** @param {string} */
|
||||
this.mime = mime;
|
||||
/** @param {string} */
|
||||
this.dateCreated = dateCreated || dateUtils.localNowDateTime();
|
||||
/** @param {string} */
|
||||
this.dateModified = dateModified;
|
||||
/** @param {string} */
|
||||
this.utcDateCreated = utcDateCreated || dateUtils.utcNowDateTime();
|
||||
/** @param {string} */
|
||||
this.utcDateModified = utcDateModified;
|
||||
|
||||
// ------ Derived attributes ------
|
||||
|
||||
/** @param {boolean} */
|
||||
this.isDecrypted = !this.isProtected;
|
||||
|
||||
this.decrypt();
|
||||
|
||||
/** @param {string|null} */
|
||||
this.flatTextCache = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
init() {
|
||||
/** @param {Branch[]} */
|
||||
this.parentBranches = [];
|
||||
/** @param {Note[]} */
|
||||
@@ -54,39 +107,6 @@ class Note extends AbstractEntity {
|
||||
this.revisionCount = null;
|
||||
}
|
||||
|
||||
update(row) {
|
||||
// ------ Database persisted attributes ------
|
||||
|
||||
/** @param {string} */
|
||||
this.noteId = row.noteId;
|
||||
/** @param {string} */
|
||||
this.title = row.title;
|
||||
/** @param {boolean} */
|
||||
this.isProtected = !!row.isProtected;
|
||||
/** @param {string} */
|
||||
this.type = row.type;
|
||||
/** @param {string} */
|
||||
this.mime = row.mime;
|
||||
/** @param {string} */
|
||||
this.dateCreated = row.dateCreated || dateUtils.localNowDateTime();
|
||||
/** @param {string} */
|
||||
this.dateModified = row.dateModified;
|
||||
/** @param {string} */
|
||||
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
|
||||
/** @param {string} */
|
||||
this.utcDateModified = row.utcDateModified;
|
||||
|
||||
// ------ Derived attributes ------
|
||||
|
||||
/** @param {boolean} */
|
||||
this.isDecrypted = !this.isProtected;
|
||||
|
||||
this.decrypt();
|
||||
|
||||
/** @param {string|null} */
|
||||
this.flatTextCache = null;
|
||||
}
|
||||
|
||||
isContentAvailable() {
|
||||
return !this.noteId // new note which was not encrypted yet
|
||||
|| !this.isProtected
|
||||
|
||||
Reference in New Issue
Block a user