mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-09 17:52:32 +08:00
30 lines
670 B
JavaScript
30 lines
670 B
JavaScript
![]() |
"use strict";
|
||
|
|
||
|
const Expression = require('./expression');
|
||
|
const NoteSet = require('../note_set');
|
||
|
|
||
|
class PropertyComparisonExp extends Expression {
|
||
|
constructor(propertyName, comparator) {
|
||
|
super();
|
||
|
|
||
|
this.propertyName = propertyName;
|
||
|
this.comparator = comparator;
|
||
|
}
|
||
|
|
||
|
execute(noteSet, searchContext) {
|
||
|
const resNoteSet = new NoteSet();
|
||
|
|
||
|
for (const note of noteSet.notes) {
|
||
|
const value = note[this.propertyName].toLowerCase();
|
||
|
|
||
|
if (this.comparator(value)) {
|
||
|
resNoteSet.add(note);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return resNoteSet;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = PropertyComparisonExp;
|