toFilterPredicate
function toFilterPredicate<Row>(input): FilterPredicate<Row>;Defined in: filters/memory.ts:487
Render an already-compiled CompiledWhere AST (from compileFilters /
compileFilterNode in @xtandard/lib/filters) to a row predicate, looking each field up in
paths (public field name → MemoryAccessor). Conditions on fields missing from
paths are dropped; null (or an AST that drops to nothing) gives a predicate that matches
every row. Evaluation uses SQL’s three-valued logic: a comparison with NULL is UNKNOWN, not
keeps UNKNOWN, and a row matches only when the whole tree is TRUE. Most code calls
buildFilterPredicate, which compiles and renders in one step.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Row |
any |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ dialect?: MemoryDialect; paths: Record<string, MemoryAccessor<Row>>; where: | CompiledWhere | null; } |
input.dialect? |
MemoryDialect |
input.paths |
Record<string, MemoryAccessor<Row>> |
input.where |
| CompiledWhere | null |
Returns
Section titled “Returns”FilterPredicate<Row>
Example
Section titled “Example”import { toFilterPredicate } from "@xtandard/lib/filters/memory";
const predicate = toFilterPredicate({ where: { type: "not", node: { type: "cond", cond: { field: "amount", op: "gt", value: 5 } } }, paths: { amount: "amount" },});predicate({ amount: 3 }); // → truepredicate({ amount: 9 }); // → falsepredicate({ amount: null }); // → false (NOT UNKNOWN is UNKNOWN)