31 lines
739 B
Rust
31 lines
739 B
Rust
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "self_join")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub uuid: Uuid,
|
|
pub uuid_ref: Option<Uuid>,
|
|
pub time: Option<Time>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(belongs_to = "Entity", from = "Column::UuidRef", to = "Column::Uuid")]
|
|
SelfReferencing,
|
|
}
|
|
|
|
pub struct SelfReferencingLink;
|
|
|
|
impl Linked for SelfReferencingLink {
|
|
type FromEntity = Entity;
|
|
|
|
type ToEntity = Entity;
|
|
|
|
fn link(&self) -> Vec<RelationDef> {
|
|
vec![Relation::SelfReferencing.def()]
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|