small refactorings

This commit is contained in:
zadam
2023-06-29 22:10:13 +02:00
parent f4ec4e58c7
commit 48029cea7c
37 changed files with 95 additions and 155 deletions

View File

@@ -39,24 +39,6 @@ function getNoteWithLabel(name, value = undefined) {
return null;
}
/**
* Does not take into account templates and inheritance
*/
function getNotesWithLabelFast(name, value) {
// optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
const attrs = becca.findAttributes('label', name);
if (value === undefined) {
return attrs.map(attr => attr.getNote());
}
value = value?.toLowerCase();
return attrs
.filter(attr => attr.value.toLowerCase() === value)
.map(attr => attr.getNote());
}
function createLabel(noteId, name, value = "") {
return createAttribute({
noteId: noteId,
@@ -130,7 +112,6 @@ function isAttributeDangerous(type, name) {
module.exports = {
getNotesWithLabel,
getNotesWithLabelFast,
getNoteWithLabel,
createLabel,
createRelation,