mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
note cache refactoring WIP
This commit is contained in:
31
src/services/search/expressions/exists.js
Normal file
31
src/services/search/expressions/exists.js
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
class ExistsExp {
|
||||
constructor(attributeType, attributeName) {
|
||||
this.attributeType = attributeType;
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
|
||||
execute(noteSet) {
|
||||
const attrs = findAttributes(this.attributeType, this.attributeName);
|
||||
const resultNoteSet = new NoteSet();
|
||||
|
||||
for (const attr of attrs) {
|
||||
const note = attr.note;
|
||||
|
||||
if (noteSet.hasNoteId(note.noteId)) {
|
||||
if (attr.isInheritable) {
|
||||
resultNoteSet.addAll(note.subtreeNotesIncludingTemplated);
|
||||
}
|
||||
else if (note.isTemplate) {
|
||||
resultNoteSet.addAll(note.templatedNotes);
|
||||
}
|
||||
else {
|
||||
resultNoteSet.add(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExistsExp;
|
||||
Reference in New Issue
Block a user