diff --git a/entity/src/candidate.rs b/entity/src/candidate.rs index 221a80e..f020e71 100644 --- a/entity/src/candidate.rs +++ b/entity/src/candidate.rs @@ -35,10 +35,18 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { + #[sea_orm(has_one = "super::parent::Entity")] + Parent, #[sea_orm(has_many = "super::session::Entity")] Session, } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Parent.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::Session.def() diff --git a/entity/src/parent.rs b/entity/src/parent.rs index 7e1b00c..4d107af 100644 --- a/entity/src/parent.rs +++ b/entity/src/parent.rs @@ -14,6 +14,19 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm( + belongs_to = "super::candidate::Entity", + from = "Column::Application", + to = "super::candidate::Column::Application" + )] + Candidate, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Candidate.def() + } +} impl ActiveModelBehavior for ActiveModel {}