FileField
Defined in: packages/schema/src/file-field.ts:6
f.file(): a text column holding a file’s URI, uploaded through :upload. See Files.
Extends
Section titled “Extends”Field<V>
Type Parameters
Section titled “Type Parameters”V
Properties
Section titled “Properties”
readonlydef:FieldTypeDef
Defined in: packages/schema/src/field.ts:108
Its field type.
Inherited from
Section titled “Inherited from”
readonlymeta:FieldMeta
Defined in: packages/schema/src/field.ts:110
What its builder methods have set.
Inherited from
Section titled “Inherited from”schema
Section titled “schema”
readonlyschema: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.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”accept()
Section titled “accept()”accept(
types):FileField<V>
Defined in: packages/schema/src/file-field.ts:8
Allowed types, checked against the type detected from the content: ['image/*', 'application/pdf'].
Parameters
Section titled “Parameters”readonly string[]
Returns
Section titled “Returns”FileField<V>
access()
Section titled “access()”access(
rules):FileField<V>
Defined in: packages/schema/src/file-field.ts:104
Role-based rules for reading and writing the file; uploading needs write access to the field.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”FileField<V>
Overrides
Section titled “Overrides”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.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”string
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”alias()
Section titled “alias()”alias(…
names):Field<V>
Defined in: packages/schema/src/field.ts:184
Other names filters may use for the field.
Parameters
Section titled “Parameters”…string[]
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”capture()
Section titled “capture()”capture(
camera?):FileField<V>
Defined in: packages/schema/src/file-field.ts:17
Opens the camera on phones and tablets instead of the file picker, the rear one unless 'user' asks for the front,
and takes only images: the image types of .accept(), or any image. Desktop browsers pick an image file.
Parameters
Section titled “Parameters”camera?
Section titled “camera?”"environment" | "user"
Returns
Section titled “Returns”FileField<V>
column()
Section titled “column()”column(
name):FileField<V>
Defined in: packages/schema/src/file-field.ts:99
The column, when it is not the snake_case of the field’s name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”FileField<V>
Overrides
Section titled “Overrides”dbDefault()
Section titled “dbDefault()”dbDefault():
Field<V>
Defined in: packages/schema/src/field.ts:179
The database supplies a value when none is given (identity, now(), …).
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”default()
Section titled “default()”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.
Parameters
Section titled “Parameters”V
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”derive()
Section titled “derive()”derive(
processors):FileField<V>
Defined in: packages/schema/src/file-field.ts:40
Values computed from each upload, written to other fields of the resource (read-only ones) in the same write as the
file: { image_width: imageSize('width') }. Clearing the file clears them.
Parameters
Section titled “Parameters”processors
Section titled “processors”Record<string, FileProcessor>
Returns
Section titled “Returns”FileField<V>
encrypted()
Section titled “encrypted()”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.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”externalUrls()
Section titled “externalUrls()”externalUrls():
FileField<V>
Defined in: packages/schema/src/file-field.ts:84
Also takes an https URL of a file elsewhere, such as https://images.example.com/photos/42.jpg, stored as it is:
never uploaded, without variants, and drawn from that address. See
External URLs.
Returns
Section titled “Returns”FileField<V>
filterable()
Section titled “filterable()”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.
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”formula()
Section titled “formula()”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.
Parameters
Section titled “Parameters”expression
Section titled “expression”string
Returns
Section titled “Returns”Field<V>
Example
Section titled “Example”amount: f.decimal({ precision: 12, scale: 2 }).formula('round(quantity * unit_price, 2)'),Inherited from
Section titled “Inherited from”lookup()
Section titled “lookup()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Field<V | null>
Example
Section titled “Example”customer_name: f.text().lookup({ via: 'customer_id', field: 'name' }).filterable(),release: f.text().lookup({ from: 'app_runtimes', via: 'app_id', field: 'release' }),Inherited from
Section titled “Inherited from”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.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”maxSize()
Section titled “maxSize()”maxSize(
size):FileField<V>
Defined in: packages/schema/src/file-field.ts:22
The largest upload, as bytes or text such as 10 MB; default 50 MB.
Parameters
Section titled “Parameters”string | number
Returns
Section titled “Returns”FileField<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.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”optional()
Section titled “optional()”optional():
FileField<V|null>
Defined in: packages/schema/src/file-field.ts:89
The column is nullable: the field may hold no file.
Returns
Section titled “Returns”FileField<V | null>
Overrides
Section titled “Overrides”placeholder()
Section titled “placeholder()”placeholder(
field):FileField<V>
Defined in: packages/schema/src/file-field.ts:48
Computes a ThumbHash of each image into a read-only text field (photo_placeholder), which the admin app shows
while the image loads. Other files leave it null.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”FileField<V>
public()
Section titled “public()”public():
FileField<V>
Defined in: packages/schema/src/file-field.ts:27
Stored with the public provider, at a permanent URL anyone with it may open.
Returns
Section titled “Returns”FileField<V>
readOnly()
Section titled “readOnly()”readOnly():
FileField<V>
Defined in: packages/schema/src/file-field.ts:94
Never written through the API.
Returns
Section titled “Returns”FileField<V>
Overrides
Section titled “Overrides”regex()
Section titled “regex()”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.
Parameters
Section titled “Parameters”RegExp
message
Section titled “message”string
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”rollup()
Section titled “rollup()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Field<V>
Example
Section titled “Example”total: f.decimal({ precision: 12, scale: 2 }).rollup({ from: 'order_lines', via: 'order_id', fn: 'sum', field: 'amount' }),Inherited from
Section titled “Inherited from”sensitive()
Section titled “sensitive()”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.
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”sizeField()
Section titled “sizeField()”sizeField(
field):FileField<V>
Defined in: packages/schema/src/file-field.ts:64
Writes each file’s size in bytes into this read-only integer or bigint field (attachment_size), so lists and
aggregates can read it. An external URL leaves it null, as its size is unknown.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”FileField<V>
sortable()
Section titled “sortable()”sortable():
Field<V>
Defined in: packages/schema/src/field.ts:194
The field may appear in order_by and in sorts.
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”storage()
Section titled “storage()”storage(
provider):FileField<V>
Defined in: packages/schema/src/file-field.ts:32
Stored with this provider of files.providers; default private.
Parameters
Section titled “Parameters”provider
Section titled “provider”string
Returns
Section titled “Returns”FileField<V>
strongSignIn()
Section titled “strongSignIn()”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.
Parameters
Section titled “Parameters”minutes?
Section titled “minutes?”number
Returns
Section titled “Returns”Field<V>
Inherited from
Section titled “Inherited from”typeField()
Section titled “typeField()”typeField(
field):FileField<V>
Defined in: packages/schema/src/file-field.ts:56
Writes each file’s media type into this read-only text field (attachment_type), so lists and aggregates can read
it, and serving and file viewers take the type from it. An external URL whose extension names no type leaves it null.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”FileField<V>
variants()
Section titled “variants()”variants(
variants,options?):FileField<V>
Defined in: packages/schema/src/file-field.ts:72
Resized copies of each image, stored beside it under these names: { card: { width: 640, height: 480, fit: 'cover', format: 'webp' } }. { original } stores that image instead of the upload. Other files get none.
Parameters
Section titled “Parameters”variants
Section titled “variants”Record<string, ImageVariant>
options?
Section titled “options?”ImageVariantOptions = {}
Returns
Section titled “Returns”FileField<V>