mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
basic entity support with lazy loaded relations
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
class Note {
|
||||
constructor(sql, row) {
|
||||
this.sql = sql;
|
||||
const Entity = require('./entity');
|
||||
|
||||
for (const key in row) {
|
||||
this[key] = row[key];
|
||||
}
|
||||
class Note extends Entity {
|
||||
async getAttributes() {
|
||||
return this.sql.getEntities("SELECT * FROM attributes WHERE noteId = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
async attributes() {
|
||||
return this.sql.getRows("SELECT * FROM attributes WHERE noteId = ?", [this.noteId]);
|
||||
async getAttribute(name) {
|
||||
return this.sql.getEntity("SELECT * FROM attributes WHERE noteId = ? AND name = ?", [this.noteId, name]);
|
||||
}
|
||||
|
||||
async revisions() {
|
||||
return this.sql.getRows("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||
async getRevisions() {
|
||||
return this.sql.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
async getTrees() {
|
||||
return this.sql.getEntities("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user