Skip to content

Build your personal knowledge base with Trilium Notes

server-ts: Port services/search/expressions/attribute_exists

Elian Doran0df488667eca
diff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.ts
similarity index 69%
rename from src/services/search/expressions/attribute_exists.js
rename to src/services/search/expressions/attribute_exists.ts
index 6d2e92d642..7a17897bff 100644
--- a/src/services/search/expressions/attribute_exists.js
+++ b/src/services/search/expressions/attribute_exists.ts
@@ -1,11 +1,19 @@
"use strict";
-const NoteSet = require('../note_set');
-const becca = require('../../../becca/becca');
-const Expression = require('./expression');
+import NoteSet = require("../note_set");
+import SearchContext = require("../search_context");
+
+import becca = require('../../../becca/becca');
+import Expression = require('./expression');
class AttributeExistsExp extends Expression {
- constructor(attributeType, attributeName, prefixMatch) {
+
+ private attributeType: string;
+ private attributeName: string;
+ private isTemplateLabel: boolean;
+ private prefixMatch: string;
+
+ constructor(attributeType: string, attributeName: string, prefixMatch: string) {
super();
this.attributeType = attributeType;
@@ -15,7 +23,7 @@ class AttributeExistsExp extends Expression {
this.prefixMatch = prefixMatch;
}
- execute(inputNoteSet, executionContext, searchContext) {
+ execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
const attrs = this.prefixMatch
? becca.findAttributesWithPrefix(this.attributeType, this.attributeName)
: becca.findAttributes(this.attributeType, this.attributeName);
@@ -40,4 +48,4 @@ class AttributeExistsExp extends Expression {
}
}
-module.exports = AttributeExistsExp;
+export = AttributeExistsExp;
diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.js
index 94b5fdd7ec..3f67e8bc88 100644
--- a/src/services/search/services/parse.js
+++ b/src/services/search/services/parse.js
@@ -9,7 +9,7 @@ const DescendantOfExp = require('../expressions/descendant_of.js');
const ParentOfExp = require('../expressions/parent_of.js');
const RelationWhereExp = require('../expressions/relation_where.js');
const PropertyComparisonExp = require('../expressions/property_comparison.js');
-const AttributeExistsExp = require('../expressions/attribute_exists.js');
+const AttributeExistsExp = require('../expressions/attribute_exists');
const LabelComparisonExp = require('../expressions/label_comparison.js');
const NoteFlatTextExp = require('../expressions/note_flat_text.js');
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');