Skip to content

textField

const textField: (input) => KyselyFieldSpec;

Defined in: filters/kysely.ts:73

Allow-list a public field as a text filter over a string column, given as a Kysely reference string ("users.name") or a raw expression such as sql`lower(users.name)`. contains/startsWith/endsWith render as ilike on Postgres and like on MySQL/SQLite, with the input’s %/_/\ escaped (plus an escape clause on MySQL/SQLite, so they match literally).

Parameter Type
input { column: KyselyTarget; }
input.column KyselyTarget

KyselyFieldSpec

import { buildWhere, textField } from "@xtandard/lib/filters/kysely";
const { where } = buildWhere({
spec: { name: textField({ column: "users.name" }) },
filters: [{ field: "name", filter: { kind: "text", operator: "contains", value: "ann" } }],
});
const { sql, parameters } = where!.compile(db); // db: your Kysely instance
// sql → '"users"."name" ilike $1', parameters → ["%ann%"]