Brick

Fields

The typed field vocabulary shared by DSL, codegen, and runtime.

Source: schema/ (fields.go, schema.go, pk.go, parent.go, singleton.go, children.go, casing.go).

FieldDef flags

FlagMeaning
required / optionalcreate-time presence (updates are always partial)
uniquein-tx precheck + 409 on 23505
defaultapplied when the key is absent
maxLength / emailstring rules → 422
hiddenexcluded from Response / Create / Update / ListInput
readonlystripped on write (PK, created_at, computed)
searchable / filterable / sortablelist surface (ILIKE search, Where filters, sort allowlist)
indexhint for BusinessIndexes()
enumclosed value set
foreign / onDeleteFK reference + delete behavior
fromsession.* / actor.* server injection
computed / normalizederived / normalized values
childrenvirtual child collection (not a column)

Chainable builders:

schema.String().Required().Searchable().Sortable()
schema.Int().Default(0)
schema.Enum("a", "b").Required()
schema.ForeignKey("team").OnDelete("cascade")
schema.String().From("session.active_team_id")

DynamicSchema extras

TenantColumn, TitleField, CompositeUniques / Indexes, SoftDeleteColumn (timestamp-only), Audited, Versioned, UpdateWritable — consumed by codegen and the exec pipeline.

PK, parent, singleton

  • PK{Column, Type, Autoname}uuid | naming_series | field: | format: | hash | prompt | autoincrement. ApplyPK injects the column as readonly.
  • ParentRef / ApplyParent — child owns a parent FK; codegen emits XxxChildInput.
  • SingletonConfig — disables create/list/delete (single-row resources like settings).
  • PolyFKDef — polymorphic references surface via BusinessIndexes().

Operations

type Operations struct{ /* per-op enable flags */ }
func (o Operations) Enabled(op string) bool // nil/empty = enabled

Casing

Title, GoFieldName, GoType / GoTypeFor, SortedFields centralize YAML ↔ Go naming so codegen, docs, and runtime agree. bun / json / query tags derive from these — don't hand-edit generated tags.

On this page