use sea_orm::entity::prelude::*; | |
use serde::{Deserialize, Serialize}; | |
pub struct Model { | |
pub id: i64, | |
pub parent_id: i64, | |
pub did: i64, | |
} | |
pub enum Relation { | |
Parent, | |
Child | |
} | |
impl RelationTrait for Relation { | |
fn def(&self) -> RelationDef { | |
match self { | |
Self::Parent => Entity::belongs_to(super::doc_info::Entity) | |
.from(Column::ParentId) | |
.to(super::doc_info::Column::Did) | |
.into(), | |
Self::Child => Entity::belongs_to(super::doc_info::Entity) | |
.from(Column::Did) | |
.to(super::doc_info::Column::Did) | |
.into(), | |
} | |
} | |
} | |
impl ActiveModelBehavior for ActiveModel {} |