Model

Derive Macro Model 

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

Derives the Model trait for a struct.

This macro inspects the struct fields and generates the necessary code to map it to a database table. It supports customization via the #[orm(...)] attribute.

ยงSupported Attributes

  • primary_key: Marks the field as a primary key.
  • unique: Adds a UNIQUE constraint.
  • index: Creates a database index.
  • create_time: Sets default value to CURRENT_TIMESTAMP.
  • size = N: Sets column size (VARCHAR(N)).
  • foreign_key = "Table::Column": Defines a Foreign Key.