Skip to main content

AroEntity

Derive Macro AroEntity 

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

Derive macro to generate Aro entity trait implementations.

Generates implementations of aro_core::Entity, fletch_orm::Entity, and sqlx::FromRow from a single annotated domain struct.

§Struct Attributes

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

§Field Attributes

  • #[aro(id)] (required, exactly one): Marks the primary key field.
  • #[aro(skip)]: Exclude a field from persistence. Skipped fields are populated with Default::default() in the generated FromRow impl.
  • #[aro(rename = "col_name")]: Override the column name.

§Example

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, AroEntity)]
#[aro(table = "users")]
pub struct User {
    #[aro(id)]
    pub id: i64,
    pub name: String,
    pub email: String,
}