diff --git a/src/model/like.rs b/src/model/like.rs index 2922857..2e072f6 100644 --- a/src/model/like.rs +++ b/src/model/like.rs @@ -11,6 +11,19 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm( + belongs_to = "super::object::Entity", + from = "Column::Likes", + to = "super::object::Column::Id", + )] + Object +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Object.def() + } +} impl ActiveModelBehavior for ActiveModel {} diff --git a/src/model/object.rs b/src/model/object.rs index 731288c..1c20ad1 100644 --- a/src/model/object.rs +++ b/src/model/object.rs @@ -116,6 +116,12 @@ pub enum Relation { #[sea_orm(has_many = "super::attachment::Entity")] Attachment, + + #[sea_orm(has_many = "super::like::Entity")] + Like, + + #[sea_orm(has_many = "super::share::Entity")] + Share, } impl Related for Entity { @@ -142,4 +148,16 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::Like.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Share.def() + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/src/model/share.rs b/src/model/share.rs index 405d176..e677cf9 100644 --- a/src/model/share.rs +++ b/src/model/share.rs @@ -11,6 +11,19 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm( + belongs_to = "super::object::Entity", + from = "Column::Shares", + to = "super::object::Column::Id", + )] + Object +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Object.def() + } +} impl ActiveModelBehavior for ActiveModel {}