mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
added getOwnedAttribute() without attr inheritance which can speed up bulk operations significantly
This commit is contained in:
parent
ca8b603bd9
commit
3bf8546d51
@ -51,7 +51,7 @@
|
|||||||
"imagemin-mozjpeg": "8.0.0",
|
"imagemin-mozjpeg": "8.0.0",
|
||||||
"imagemin-pngquant": "8.0.0",
|
"imagemin-pngquant": "8.0.0",
|
||||||
"ini": "1.3.5",
|
"ini": "1.3.5",
|
||||||
"jimp": "0.7.0",
|
"jimp": "0.8.0",
|
||||||
"mime-types": "2.1.24",
|
"mime-types": "2.1.24",
|
||||||
"moment": "2.24.0",
|
"moment": "2.24.0",
|
||||||
"multer": "1.4.2",
|
"multer": "1.4.2",
|
||||||
|
@ -196,8 +196,30 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @returns {Promise<Attribute[]>} attributes belonging to this specific note (excludes inherited attributes)
|
* @returns {Promise<Attribute[]>} attributes belonging to this specific note (excludes inherited attributes)
|
||||||
*/
|
*/
|
||||||
async getOwnedAttributes() {
|
async getOwnedAttributes(type, name) {
|
||||||
return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user