sea_orm::entity::prelude

Derive Macro DeriveIden

source
#[derive(DeriveIden)]
{
    // Attributes available to this derive:
    #[sea_orm]
}
Expand description

The DeriveIden derive macro will implement sea_orm::sea_query::Iden for simplify Iden implementation.

ยงUsage

use sea_orm::{DeriveIden, Iden};

#[derive(DeriveIden)]
pub enum MyClass {
    Table, // this is a special case, which maps to the enum's name
    Id,
    #[sea_orm(iden = "turtle")]
    Title,
    Text,
}

#[derive(DeriveIden)]
struct MyOther;

assert_eq!(MyClass::Table.to_string(), "my_class");
assert_eq!(MyClass::Id.to_string(), "id");
assert_eq!(MyClass::Title.to_string(), "turtle"); // renamed!
assert_eq!(MyClass::Text.to_string(), "text");
assert_eq!(MyOther.to_string(), "my_other");