Field Types Reference

Complete reference for all built-in field types and their options.

Base options

All field types accept these common options:


          type BaseFieldOptions<TValue = unknown> = {
  required?: boolean;        // default: false
  unique?: boolean;          // default: false
  hidden?: boolean;          // default: false
  defaultValue?: TValue;
  validate?: (value: TValue) => boolean | string;
  admin?: {
    component?: () => Promise<unknown>;
    condition?: (data: Record<string, unknown>) => boolean;
  };
};
        

text


          text(name: string, opts?: BaseFieldOptions<string>): TextField
        
  • Storage: Column (text)
  • API value: string

slug


          slug(name: string, opts?: BaseFieldOptions<string>): TextField
        
  • Storage: Column (text)
  • API value: string
  • Default: unique: true
  • Special: Supports $glob filter operator for path matching

number


          number(name: string, opts?: BaseFieldOptions<number>): NumberField
        
  • Storage: Column (integer)
  • API value: number

boolean


          boolean(name: string, opts?: BaseFieldOptions<boolean>): BooleanField
        
  • Storage: Column (boolean)
  • API value: boolean

date


          date(name: string, opts?: BaseFieldOptions<string>): DateField
        
  • Storage: Column (timestamptz)
  • API value: string (ISO 8601)

select


          select<T extends readonly string[]>(
  name: string,
  opts: BaseFieldOptions<T[number]> & { options: T }
): SelectField<T>
        
  • Storage: Column (text)
  • API value: One of the specified options
  • Type-safe: Options are inferred as a literal union type

json


          json(name: string, opts?: BaseFieldOptions): JsonField
        
  • Storage: JSONB
  • API value: Any JSON value
  • Limitation: Cannot be unique or used for sorting

relation


          relation(name: string, opts: {
  to: EntityDef | string | Array<EntityDef | string>;
  multiple?: boolean;
} & BaseFieldOptions): RelationField
        
  • Storage: FK column (single) or junction table (multiple)
  • API value: UUID string (single), UUID array (multiple), or resolved object(s) with ?resolve

Single relation

Creates a {name}_id column with a foreign key constraint.

Multiple relation

Creates a {entity}_{name} junction table with sourceId, targetId, and position columns.

Polymorphic relation

When to is an array, the target entity type is stored alongside the ID.

object


          object(name: string, opts: {
  fields: AnyField[];
} & BaseFieldOptions): ObjectField
        
  • Storage: JSONB
  • API value: Object matching the field structure

blocks


          blocks(name: string, opts: {
  of: ObjectField[];
} & BaseFieldOptions): BlocksField
        
  • Storage: JSONB (array)
  • API value: Array of objects, each with a _block discriminator

          [
  { "_block": "hero", "heading": "Welcome" },
  { "_block": "cta", "text": "Sign up", "url": "/signup" }
]
        

array


          array(name: string, opts: {
  of: AnyField;
} & BaseFieldOptions): ArrayField
        
  • Storage: JSONB
  • of: A single field definition — use a primitive field for flat arrays, or an object field for arrays of objects
  • API value: Array of primitives or array of objects, depending on of
  • Admin: Add/remove/reorder items with up/down buttons

Do not use array() to hold multiple references to another collection — use relation() with multiple: true instead. Wrapping a relation in an array stores IDs as JSONB, losing referential integrity, cross-entity filtering, and resolution. See Handling multiple relations.

Layout directives

Layout directives are admin-only — no storage, no migration impact.


          tabs(tabDefs: Array<{ label: string; fields: AnyField[] }>): TabsDirective

collapsible(
  label: string,
  fields: AnyField[],
  opts?: { defaultOpen?: boolean }  // default: true
): CollapsibleDirective

row(fields: AnyField[]): RowDirective
        

Directives can be nested and combined with regular fields in any fields array.

Previous

REST API

Next

Config Reference