Skip to main content

Model

Derive Macro Model 

Source
#[derive(Model)]
{
    // Attributes available to this derive:
    #[model]
    #[field]
}
Expand description

Derive macro for Rango models.

Generates:

  • impl Model for MyStruct with table_name() and schema()
  • Table name defaults to snake_case of the struct name (e.g. UserProfile → user_profile)

§Example

ⓘ
#[derive(Model)]
struct Article {
    id: FieldUuid,
    title: FieldVarchar<1, 255>,
    body: Option<FieldText>,
    #[field(index)]
    slug: FieldVarchar<1, 100>,
    #[field(auto_now_add)]
    created_at: FieldDateTime,
}