use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "fruit")] pub struct Model { #[sea_orm(primary_key)] #[cfg_attr(feature = "with-json", serde(skip_deserializing))] pub id: i32, pub name: String, pub cake_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm( belongs_to = "super::cake::Entity", from = "Column::CakeId", to = "super::cake::Column::Id" )] Cake, } impl Related for Entity { fn to() -> RelationDef { Relation::Cake.def() } } impl ActiveModelBehavior for ActiveModel {}