use standard search to find notes with same attrs

This commit is contained in:
zadam
2020-06-18 22:28:18 +02:00
parent a87e59cecb
commit f700e6e12b
7 changed files with 93 additions and 58 deletions

View File

@@ -41,27 +41,6 @@ const BUILTIN_ATTRIBUTES = [
{ type: 'relation', name: 'renderNote', isDangerous: true }
];
async function getNotesWithAttribute(type, name, value) {
let valueCondition = "";
let params = [type, name];
if (value !== undefined) {
valueCondition = " AND attributes.value = ?";
params.push(value);
}
return await repository.getEntities(`
SELECT notes.*
FROM notes
JOIN attributes USING (noteId)
WHERE notes.isDeleted = 0
AND attributes.isDeleted = 0
AND attributes.type = ?
AND attributes.name = ?
${valueCondition}
ORDER BY position`, params);
}
async function getNotesWithLabel(name, value) {
let valueCondition = "";
let params = [name];
@@ -155,7 +134,6 @@ function getBuiltinAttributeNames() {
}
module.exports = {
getNotesWithAttribute,
getNotesWithLabel,
getNotesWithLabels,
getNoteWithLabel,