repository has now first level cache

This commit is contained in:
zadam
2020-04-06 20:59:04 +02:00
parent 081693f263
commit 5c0355718f
7 changed files with 45 additions and 20 deletions

View File

@@ -45,11 +45,7 @@ class Attribute extends Entity {
* @returns {Promise<Note|null>}
*/
async getNote() {
if (!this.__note) {
this.__note = await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
return this.__note;
return await repository.getNote(this.noteId);
}
/**
@@ -64,11 +60,7 @@ class Attribute extends Entity {
return null;
}
if (!this.__targetNote) {
this.__targetNote = await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.value]);
}
return this.__targetNote;
return await repository.getNote(this.value);
}
/**

View File

@@ -28,9 +28,14 @@ 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 {Note|null} */
/** @returns {Promise<Note|null>} */
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
return await repository.getNote(this.noteId);
}
/** @returns {Promise<Note|null>} */
async getParentNote() {
return await repository.getNote(this.parentNoteId);
}
async beforeSaving() {

View File

@@ -48,7 +48,7 @@ class NoteRevision extends Entity {
}
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
return await repository.getNote(this.noteId);
}
/** @returns {boolean} true if the note has string content (not binary) */