textField
const textField: (input) => MongoFieldSpec;Defined in: filters/mongo.ts:55
Allow-list a public field as a text filter over a document field path ("name",
"address.city"). contains/startsWith/endsWith become a case-insensitive $regex
(input escaped); like/ilike patterns are translated to a regex.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ path: string; } |
input.path |
string |
Returns
Section titled “Returns”Example
Section titled “Example”import { buildFilter, textField } from "@xtandard/lib/filters/mongo";
const { filter } = buildFilter({ spec: { name: textField({ path: "name" }) }, filters: [{ field: "name", filter: { kind: "text", operator: "contains", value: "ann" } }],});// filter → { name: { $regex: "ann", $options: "i" } }