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";
|
"use strict";
|
||||||
|
|
||||||
const Expression = require('./expression');
|
import Expression = require('./expression');
|
||||||
const NoteSet = require('../note_set');
|
import NoteSet = require('../note_set');
|
||||||
const log = require('../../log');
|
import log = require('../../log');
|
||||||
const becca = require('../../../becca/becca');
|
import becca = require('../../../becca/becca');
|
||||||
|
import SearchContext = require('../search_context');
|
||||||
|
|
||||||
class AncestorExp extends Expression {
|
class AncestorExp extends Expression {
|
||||||
constructor(ancestorNoteId, ancestorDepth) {
|
|
||||||
|
private ancestorNoteId: string;
|
||||||
|
private ancestorDepthComparator;
|
||||||
|
|
||||||
|
ancestorDepth: string;
|
||||||
|
|
||||||
|
constructor(ancestorNoteId: string, ancestorDepth: string) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.ancestorNoteId = ancestorNoteId;
|
this.ancestorNoteId = ancestorNoteId;
|
||||||
@ -14,7 +21,7 @@ class AncestorExp extends Expression {
|
|||||||
this.ancestorDepthComparator = this.getComparator(ancestorDepth);
|
this.ancestorDepthComparator = this.getComparator(ancestorDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(inputNoteSet, executionContext, searchContext) {
|
execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
|
||||||
const ancestorNote = becca.notes[this.ancestorNoteId];
|
const ancestorNote = becca.notes[this.ancestorNoteId];
|
||||||
|
|
||||||
if (!ancestorNote) {
|
if (!ancestorNote) {
|
||||||
@ -44,7 +51,7 @@ class AncestorExp extends Expression {
|
|||||||
return depthConformingNoteSet;
|
return depthConformingNoteSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
getComparator(depthCondition) {
|
getComparator(depthCondition: string): ((depth: number) => boolean) | null {
|
||||||
if (!depthCondition) {
|
if (!depthCondition) {
|
||||||
return null;
|
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
|
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;
|
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 NoteFlatTextExp = require('../expressions/note_flat_text.js');
|
||||||
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');
|
const NoteContentFulltextExp = require('../expressions/note_content_fulltext.js');
|
||||||
const OrderByAndLimitExp = require('../expressions/order_by_and_limit.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 buildComparator = require('./build_comparator.js');
|
||||||
const ValueExtractor = require('../value_extractor');
|
const ValueExtractor = require('../value_extractor');
|
||||||
const utils = require('../../utils');
|
const utils = require('../../utils');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user