Skip to content

buildFilterNodePredicate

function buildFilterNodePredicate<Row>(input): object;

Defined in: filters/memory.ts:612

Compile a recursive and/or/not FilterNode tree into a row predicate. Same allow-list, resolveDate and dialect rules as buildFilterPredicate.

Type Parameter Default type
Row any
Parameter Type
input { dialect?: MemoryDialect; node: FilterNode; resolveDate?: DateFilterResolver; spec: MemoryFilterSpec<Row>; }
input.dialect? MemoryDialect
input.node FilterNode
input.resolveDate? DateFilterResolver
input.spec MemoryFilterSpec<Row>

object

Name Type Defined in
predicate FilterPredicate<Row> filters/memory.ts:617
import { buildFilterNodePredicate, numberField, textField } from "@xtandard/lib/filters/memory";
const spec = { name: textField({ path: "name" }), amount: numberField({ path: "amount" }) };
const { predicate } = buildFilterNodePredicate({ spec, node: { type: "or", nodes: [
{ type: "column", field: "name", filter: { kind: "text", operator: "eq", value: "Rent" } },
{ type: "not", node: { type: "column", field: "amount", filter: { kind: "number", operator: "lt", value: 0 } } },
] } });
predicate({ name: "Rent", amount: -5 }); // → true
predicate({ name: "Fee", amount: 10 }); // → true
predicate({ name: "Fee", amount: null }); // → false (both branches are FALSE or UNKNOWN)