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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Row |
any |
Parameters
Section titled “Parameters”| 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> |
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
predicate |
FilterPredicate<Row> |
filters/memory.ts:617 |
Example
Section titled “Example”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 }); // → truepredicate({ name: "Fee", amount: 10 }); // → truepredicate({ name: "Fee", amount: null }); // → false (both branches are FALSE or UNKNOWN)