textField
function textField(input): FieldSpec;Defined in: filters/drizzle/spec.ts:80
Allow-list a public field as a text filter over a Drizzle string column (text,
varchar, …). contains/startsWith/endsWith render as ilike with the input’s
%/_/\ escaped; on a SQLite or MySQL column, as like … escape instead. Passing a
non-string column is a compile error.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ column: ColumnOf<string>; } |
input.column |
ColumnOf<string> |
Returns
Section titled “Returns”Example
Section titled “Example”import { PgDialect, pgTable, text } from "drizzle-orm/pg-core";import { buildWhere, textField } from "@xtandard/lib/filters/drizzle";
const users = pgTable("users", { name: text("name") });const { where } = buildWhere({ spec: { name: textField({ column: users.name }) }, filters: [{ field: "name", filter: { kind: "text", operator: "contains", value: "ann" } }],});const { sql, params } = new PgDialect().sqlToQuery(where!);// sql → '"users"."name" ilike $1', params → ["%ann%"]