use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "cake")] pub struct Model { #[sea_orm(primary_key)] pub id: i32, pub name: String, #[sea_orm(column_type = "Decimal(Some((19, 4)))")] pub price: Decimal, pub bakery_id: Option, pub gluten_free: bool, pub serial: Uuid, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm( belongs_to = "super::bakery::Entity", from = "Column::BakeryId", to = "super::bakery::Column::Id", on_update = "Cascade", on_delete = "Cascade" )] Bakery, #[sea_orm(has_many = "super::lineitem::Entity")] Lineitem, } impl Related for Entity { fn to() -> RelationDef { Relation::Bakery.def() } } impl Related for Entity { fn to() -> RelationDef { super::cakes_bakers::Relation::Baker.def() } fn via() -> Option { Some(super::cakes_bakers::Relation::Cake.def().rev()) } } impl Related for Entity { fn to() -> RelationDef { Relation::Lineitem.def() } } impl ActiveModelBehavior for ActiveModel {}