arrayField
function arrayField(input): FieldSpec;Defined in: filters/drizzle/spec.ts:174
Allow-list a public field as an array filter over a Postgres array column (any element
type). arrayContains/arrayContained/arrayOverlaps render as @>/<@/&&.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ column: AnyColumn; } |
input.column |
AnyColumn |
Returns
Section titled “Returns”Example
Section titled “Example”import { PgDialect, pgTable, text } from "drizzle-orm/pg-core";import { arrayField, buildWhere } from "@xtandard/lib/filters/drizzle";
const posts = pgTable("posts", { tags: text("tags").array() });const { where } = buildWhere({ spec: { tags: arrayField({ column: posts.tags }) }, filters: [{ field: "tags", filter: { kind: "array", operator: "arrayOverlaps", values: ["ts", "js"] } }],});const { sql, params } = new PgDialect().sqlToQuery(where!);// sql → '"posts"."tags" && $1', params → ['{"ts","js"}']