feat: candidate & parent relations

This commit is contained in:
EETagent 2022-10-30 13:25:18 +01:00
parent 0e154ae3f9
commit 03a9268848
2 changed files with 22 additions and 1 deletions

View file

@ -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<super::parent::Entity> for Entity {
fn to() -> RelationDef {
Relation::Parent.def()
}
}
impl Related<super::session::Entity> for Entity {
fn to() -> RelationDef {
Relation::Session.def()

View file

@ -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<super::candidate::Entity> for Entity {
fn to() -> RelationDef {
Relation::Candidate.def()
}
}
impl ActiveModelBehavior for ActiveModel {}