Skip to content

enumField

const enumField: <Row>(input) => MemoryFieldSpec<Row>;

Defined in: filters/memory.ts:141

Allow-list a public field as an enum filter (eq/ne/inArray/notInArray/null checks) over a row value read by path. As in SQL, ne and notInArray never match a NULL.

Type Parameter Default type
Row any
Parameter Type
input { path: MemoryAccessor<Row>; }
input.path MemoryAccessor<Row>

MemoryFieldSpec<Row>

import { buildFilterPredicate, enumField } from "@xtandard/lib/filters/memory";
const { predicate } = buildFilterPredicate({
spec: { status: enumField({ path: "status" }) },
filters: [{ field: "status", filter: { kind: "enum", operator: "notInArray", values: ["done"] } }],
});
predicate({ status: "open" }); // → true
predicate({ status: null }); // → false (NULL NOT IN (…) is UNKNOWN)