Cheatsheet

A one-page scannable reference to every .forge type, modifier, relation, and directive, plus a kitchen-sink schema.

A compact lookup for the whole .forge language. Follow the links for the full detail.

Scalar types#

TypeRustTSIndexable?
u32 u64 i32 i64samenumber
f64f64numberfilter/sort (no ordered index)
boolboolboolean
stringStringstring✅ (exact-match)
char(N)[u8; N]string✅ (fixed-size; struct-safe)
uuidUuidstring
timestampi64number
decimalDecimalstring✅ (normalized key)
jsonserde_json::Valueunknown

No text type. See scalar types.

Modifiers#

SigilPositionMeaningNotes
+prefixauto-generateu32/u64/uuid/timestamp only
&prefixunique (enforced)any type; also indexes
^prefixindexedany indexable type
?postfix (or prefix)nullableany type

Combine freely: id: +uuid, email: ^&string, bio: string?, external: +uuid?. See modifiers.

Relations#

SyntaxKind
[Model]one-to-many (virtual)
*Modelrequired FK
?Modeloptional FK
[..] / [..] on both sidesmany-to-many (junction)
[type; N]fixed-size array (fixed-size element)
StructName / StructName?inline struct (fixed-size fields only)

Traversal is UUID-keyed-target only. See relations.

Enums#

enum Status { Active, Suspended, Closed }
Account { id: +uuid  status: ^Status }

PascalCase name + variants; 1-byte discriminant; serialized as the variant name; filterable / sortable (declaration order) / indexable. See enums.

Directives#

Enforced: @min @max @length @email @url @pattern/@regex (→ 422), @on_delete(restrict|cascade|set_null) (→ 409 / cascade / null).

Semantic-only markers: @default @computed @fulltext @materialized @relations(*|fields) (component-only).

Model-level: @index(a, b, ...) (composite, ≥ 2 fields), @projection(name: cols), @soft_delete.

Args accept numbers, bare idents, and quoted strings. See directives and indexes & projections.

Comments#

// line comments only. No block comments (/* */). Newlines are significant; no semicolons. See comments & whitespace.

Not supported#

~ auto-update · text type · block comments /* */.

Kitchen-sink schema#

// Every construct in one file.
enum OrderStatus { Placed, Paid, Shipped, Delivered, Cancelled }
 
struct GeoPoint {
  latitude: f64
  longitude: f64
}
 
User {
  id: +uuid
  email: ^&string @email
  name: string @length(1, 100)
  bio: string?
  home: GeoPoint?
  balance: decimal
  metadata: json?
  created_at: +timestamp
  orders: [Order]
  tags: [Tag]
}
 
Order {
  id: +uuid
  status: ^OrderStatus
  total: decimal @min(0)
  placed_at: +timestamp
  customer: *User @on_delete(cascade)
  courier: ?User @on_delete(set_null)
  scores: [u32; 5]
  @index(customer, placed_at)
  @projection(summary: status, total, placed_at)
  @soft_delete
}
 
Tag {
  id: +uuid
  label: ^&string @length(1, 50)
  users: [User]
}

Search documentation

Find pages across the ForgeDB docs