f
constf:object
Defined in: packages/schema/src/fields.ts:49
The field builders of a resource’s .fields({ ... }), one per field type. Each returns a Field whose options
chain in any order. See Field types.
Type Declaration
Section titled “Type Declaration”bigint
Section titled “bigint”bigint: () =>
Field<string>
A 64-bit integer: an int8 column, a string in the API so that all 64 bits survive.
Returns
Section titled “Returns”Field<string>
boolean
Section titled “boolean”boolean: () =>
Field<boolean>
A bool column.
Returns
Section titled “Returns”Field<boolean>
country
Section titled “country”country: () =>
Field<string>
An ISO 3166-1 alpha-2 country code such as NL, in a text column.
Returns
Section titled “Returns”Field<string>
currency
Section titled “currency”currency: () =>
Field<string>
An ISO 4217 currency code such as EUR, in a text column.
Returns
Section titled “Returns”Field<string>
date: () =>
Field<string>
A date column, 2026-10-08 in the API.
Returns
Section titled “Returns”Field<string>
decimal
Section titled “decimal”decimal: (
o) =>Field<string>
An exact decimal of precision digits, scale of them after the point: a numeric column, a string in the API.
Parameters
Section titled “Parameters”precision
Section titled “precision”number
number
Returns
Section titled “Returns”Field<string>
enum: <
T>(values) =>Field<T[number]>
One of values: a Postgres enum, or text with a CHECK (... IN ...). The record type is the union of the values.
Type Parameters
Section titled “Type Parameters”T extends readonly string[]
Parameters
Section titled “Parameters”values
Section titled “values”T
Returns
Section titled “Returns”Field<T[number]>
file: () =>
FileField<string>
A file: its column holds {provider}:{path}?name=…&size=… as text, and responses carry { uri, name, type, size, url }.
Returns
Section titled “Returns”FileField<string>
integer
Section titled “integer”integer: () =>
Field<number>
A 32-bit or smaller integer: an int2 or int4 column. Takes .min() and .max().
Returns
Section titled “Returns”Field<number>
json: () =>
Field<JSONType>
Any JSON: a json or jsonb column.
Returns
Section titled “Returns”Field<JSONType>
relation
Section titled “relation”relation: (
resource) =>RelationField<string|number>
The key of a record of resource, in that resource’s key column(s); the admin shows the other record’s title and
links to it. A relation to a resource with a key of several columns names them with .columns().
Parameters
Section titled “Parameters”resource
Section titled “resource”string
Returns
Section titled “Returns”RelationField<string | number>
text: () =>
Field<string>
Text: a text, varchar or bpchar column. Takes .min(), .max() (length) and .regex().
Returns
Section titled “Returns”Field<string>
timestamp
Section titled “timestamp”timestamp: () =>
Field<string>
A timestamp or timestamptz column, ISO 8601 with an offset in the API.
Returns
Section titled “Returns”Field<string>
uuid: () =>
Field<string>
A uuid column.
Returns
Section titled “Returns”Field<string>
Example
Section titled “Example”.fields({ id: f.integer().readOnly().filterable().sortable().dbDefault(), status: f.enum(['booked', 'ready', 'collected']).default('booked').filterable(), customer_id: f.relation('customers').filterable(), estimate: f.decimal({ precision: 8, scale: 2 }), notes: f.text().optional().column('internal_notes'),})