Skip to main content

model

Attribute Macro model 

Source
#[model]
Expand description

Attribute macro: adds an implicit primary key, then derives Model.

  • no PK declared: injects pub id: FieldUuid as the first field
  • #[rango::model(pk = "bigint")]: injects id: FieldAutoBigInt (database-generated); "int" gives FieldAutoInt, "uuid" is the default
  • a PK already exists (id field or #[field(primary_key)]): nothing is injected
  • #[derive(Model)] is added unless the struct already has it

The default is not read from rango.toml: cargo does not track that file, so builds would go stale when it changes.

ⓘ
#[rango::model]
struct Article { title: FieldVarchar<1, 200> }