mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Port services/search/expressions/ancestor
This commit is contained in:
parent
ce60fc0c3a
commit
414515bc87
@ -1,12 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const Expression = require('./expression');
|
||||
const NoteSet = require('../note_set');
|
||||
const log = require('../../log');
|
||||
const becca = require('../../../becca/becca');
|
||||
import Expression = require('./expression');
|
||||
import NoteSet = require('../note_set');
|
||||
import log = require('../../log');
|
||||
import becca = require('../../../becca/becca');
|
||||
import SearchContext = require('../search_context');
|
||||
|
||||
class AncestorExp extends Expression {
|
||||
constructor(ancestorNoteId, ancestorDepth) {
|
||||
|
||||
private ancestorNoteId: string;
|
||||
private ancestorDepthComparator;
|
||||
|
||||
ancestorDepth: string;
|
||||
|
||||
constructor(ancestorNoteId: string, ancestorDepth: string) {
|
||||
super();
|
||||
|
||||
this.ancestorNoteId = ancestorNoteId;
|
||||
@ -14,7 +21,7 @@ class AncestorExp extends Expression {
|
||||
this.ancestorDepthComparator = this.getComparator(ancestorDepth);
|
||||
}
|
||||
|
||||
execute(inputNoteSet, executionContext, searchContext) {
|
||||
execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
|
||||
const ancestorNote = becca.notes[this.ancestorNoteId];
|
||||
|
||||
if (!ancestorNote) {
|
||||
@ -44,7 +51,7 @@ class AncestorExp extends Expression {
|
||||
return depthConformingNoteSet;
|
||||
}
|
||||
|
||||
getComparator(depthCondition) {
|
||||
getComparator(depthCondition: string): ((depth: number) => boolean) | null {
|
||||
if (!depthCondition) {
|
||||
return null;
|
||||
}
|
@ -10,12 +10,6 @@ abstract class Expression {
|
||||
this.name = this.constructor.name; // for DEBUG mode to have expression name as part of dumped JSON
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NoteSet} inputNoteSet
|
||||
* @param {object} executionContext
|
||||
* @param {SearchContext} searchContext
|
||||
* @returns {NoteSet}
|
||||
*/
|
||||
abstract execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext): NoteSet;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ const LabelComparisonExp = require('../expressions/label_comparison.js');
|
||||
const NoteFlatTextExp = require('../expressions/note_flat_text.js');
|
||||
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');
|
||||
const OrderByAndLimitExp = require('../expressions/order_by_and_limit.js');
|
||||
const AncestorExp = require('../expressions/ancestor.js');
|
||||
const AncestorExp = require('../expressions/ancestor');
|
||||
const buildComparator = require('./build_comparator.js');
|
||||
const ValueExtractor = require('../value_extractor');
|
||||
const utils = require('../../utils');
|
||||
|
Loading…
x
Reference in New Issue
Block a user