Skip to main content

Entity

Derive Macro Entity 

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

Derive macro to generate fletch_orm::Entity trait implementation.

§Struct Attributes

  • #[fletch(table = "table_name")]: Override the table name (default: snake_case pluralized struct name).

§Field Attributes

  • #[fletch(id)]: Mark the primary key field (required, exactly one).
  • #[fletch(skip)]: Exclude a field from persistence.
  • #[fletch(rename = "col_name")]: Override the column name.

§Example

#[derive(Entity)]
#[fletch(table = "users")]
pub struct User {
    #[fletch(id)]
    pub id: i64,
    pub name: String,
    #[fletch(skip)]
    pub cached_display: String,
}