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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Row |
any |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ path: MemoryAccessor<Row>; } |
input.path |
MemoryAccessor<Row> |
Returns
Section titled “Returns”MemoryFieldSpec<Row>
Example
Section titled “Example”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"] }); // → truepredicate({ tags: [] }); // → false