Skip to content

Field

Defined in: packages/schema/src/field.ts:102

A field of a resource, holding values of type V, as f builds it. Every option returns a new field, so they chain in any order. See Field options.

V

readonly def: FieldTypeDef

Defined in: packages/schema/src/field.ts:108

Its field type.


readonly meta: FieldMeta

Defined in: packages/schema/src/field.ts:110

What its builder methods have set.


readonly schema: ZodType<V>

Defined in: packages/schema/src/field.ts:104

The Zod schema a value is checked with on every create and update: the type’s, nullable and defaulted as set.

access(rules): Field<V>

Defined in: packages/schema/src/field.ts:143

Role-based rules for reading and writing this column. They never see a record, so the set of readable columns is fixed per request. A field without a rule follows its resource.

FieldAccess

Field<V>


ai(o): Field<V>

Defined in: packages/schema/src/field.ts:217

A job fills the field from prompt, {{field}} replaced by the record’s values, after a create, and after an update that changes a field the prompt names, as the user who wrote; see AI fields and actions.

string

Field<V>


alias(…names): Field<V>

Defined in: packages/schema/src/field.ts:184

Other names filters may use for the field.

…string[]

Field<V>


column(name): Field<V>

Defined in: packages/schema/src/field.ts:120

The column, when it is not the snake_case of the field’s name, such as 'EMP_NAME'.

string

Field<V>


dbDefault(): Field<V>

Defined in: packages/schema/src/field.ts:179

The database supplies a value when none is given (identity, now(), …).

Field<V>


default(value): Field<V>

Defined in: packages/schema/src/field.ts:135

The value a create uses when none is given; the admin’s create form shows it.

V

Field<V>


encrypted(): Field<Encrypted | V>

Defined in: packages/schema/src/field.ts:161

Stored encrypted with the app’s own key (PROTOBASE_ENCRYPTION_KEY): the database only ever holds ciphertext. It is sensitive too, so only its reveal decrypts it, and record rules, validators and hooks get a set stored value as encrypted, never the value. Only f.text() takes it. See Encrypted fields.

Field<Encrypted | V>


filterable(): Field<V>

Defined in: packages/schema/src/field.ts:189

The field may appear in filter, in filter widgets and in the filters of composed pages. Give it an index.

Field<V>


formula(expression): Field<V>

Defined in: packages/schema/src/field.ts:249

The database computes the field from the record’s other number fields: a generated column. expression takes numbers, fields, + - * /, parentheses, coalesce(a, b, ...) and round(x, digits), computed exactly as decimals and stored as the field’s type. Read-only; protobase migration writes the column. See Rollups and formulas.

string

Field<V>

amount: f.decimal({ precision: 12, scale: 2 }).formula('round(quantity * unit_price, 2)'),

lookup(o): Field<V | null>

Defined in: packages/schema/src/field.ts:267

Shows a field of the record this one is linked to, read with the record in the same query. Without from that record is the one this record’s relation via points at; with from it is the one record of from whose relation via points at this record. The field’s type is the linked field’s. It is read-only and empty when there is no linked record or the caller may not read it; a caller who may not read the linked field does not see it at all. See Lookups.

Lookup

Field<V | null>

customer_name: f.text().lookup({ via: 'customer_id', field: 'name' }).filterable(),
release: f.text().lookup({ from: 'app_runtimes', via: 'app_id', field: 'release' }),

max(value): Field<V>

Defined in: packages/schema/src/field.ts:209

The greatest value of an integer, or the longest length of a text. Only f.integer() and f.text() take it.

number

Field<V>


min(value): Field<V>

Defined in: packages/schema/src/field.ts:204

The least value of an integer, or the shortest length of a text. Only f.integer() and f.text() take it.

number

Field<V>


optional(): Field<V | null>

Defined in: packages/schema/src/field.ts:130

The column is nullable: the value may be null.

Field<V | null>


readOnly(): Field<V>

Defined in: packages/schema/src/field.ts:125

Never written through the API: ids, computed columns, audit timestamps.

Field<V>


regex(re, message): Field<V>

Defined in: packages/schema/src/field.ts:199

Text must match re; a value that does not gets an issue with message. Only f.text() takes it.

RegExp

string

Field<V>


rollup(o): Field<V>

Defined in: packages/schema/src/field.ts:234

The database keeps the field: a column a trigger on from’s table sets to fn of the records whose via points at this record, in the transaction that writes them. count and sum are 0 without records; avg, min and max are empty, so their fields are .optional(). Empty values are left out, as in SQL. Read-only; protobase migration writes the column and its trigger. See Rollups and formulas.

Rollup

Field<V>

total: f.decimal({ precision: 12, scale: 2 }).rollup({ from: 'order_lines', via: 'order_id', fn: 'sum', field: 'amount' }),

sensitive(): Field<V>

Defined in: packages/schema/src/field.ts:151

Hidden like a password: never part of a list, record, search or write response. A caller who may read it fetches the value of one record on its own (POST /{{resource}}/{{key}}:reveal), and every reveal is published as an audit event.

Field<V>


sortable(): Field<V>

Defined in: packages/schema/src/field.ts:194

The field may appear in order_by and in sorts.

Field<V>


strongSignIn(o?): Field<V>

Defined in: packages/schema/src/field.ts:172

Revealing it needs a strong sign-in: one that proved a passkey or a second step, made or confirmed in the last minutes (15 by default). Otherwise the reveal is refused with 403 strong-sign-in-required, and the record page asks the person to confirm it’s them first. It is sensitive too. See Recent strong sign-in.

number

Field<V>