Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added getOwnedAttribute() without attr inheritance which can speed up bulk operations significantly
zadam3bf8546d516c
diff --git a/package.json b/package.jsonindex 79354d798e..9dd24b3a6d 100644--- a/package.json+++ b/package.json@@ -51,7 +51,7 @@"imagemin-mozjpeg": "8.0.0","imagemin-pngquant": "8.0.0","ini": "1.3.5",- "jimp": "0.7.0",+ "jimp": "0.8.0","mime-types": "2.1.24","moment": "2.24.0","multer": "1.4.2",diff --git a/src/entities/note.js b/src/entities/note.jsindex 3cf05d0e4f..8524d9a69e 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -196,8 +196,30 @@ class Note extends Entity {/*** @returns {Promise<Attribute[]>} attributes belonging to this specific note (excludes inherited attributes)*/- async getOwnedAttributes() {- return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);+ async getOwnedAttributes(type, name) {+ let query = `SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`;+ const params = [this.noteId];++ if (type) {+ query += ` AND type = ?`;+ params.push(type);+ }++ if (name) {+ query += ` AND name = ?`;+ params.push(name);+ }++ return await repository.getEntities(query, params);+ }++ /**+ * @returns {Promise<Attribute>} attribute belonging to this specific note (excludes inherited attributes)+ */+ async getOwnedAttribute(type, name) {+ const attrs = await this.getOwnedAttributes(type, name);++ return attrs.length > 0 ? attrs[0] : null;}/**