diff --git a/package.json b/package.json index 79354d798..9dd24b3a6 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.js index 3cf05d0e4..8524d9a69 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -196,8 +196,30 @@ class Note extends Entity { /** * @returns {Promise} 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 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; } /**