Skip to content

arrayField

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

Defined in: filters/memory.ts:176

Allow-list a public field as an array filter over a row value read by path that holds an array. arrayContains is Postgres @> (the row has every value), arrayContained is <@ (every row element is a value) and arrayOverlaps is && (at least one in common).

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

MemoryFieldSpec<Row>

import { arrayField, buildFilterPredicate } from "@xtandard/lib/filters/memory";
const { predicate } = buildFilterPredicate({
spec: { tags: arrayField({ path: "tags" }) },
filters: [{ field: "tags", filter: { kind: "array", operator: "arrayOverlaps", values: ["ts", "js"] } }],
});
predicate({ tags: ["go", "ts"] }); // → true
predicate({ tags: [] }); // → false