feat: like and share relations with object

This commit is contained in:
əlemi 2024-04-30 00:53:57 +02:00
parent 97ed5d60b1
commit f0cdd4bd7a
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 46 additions and 2 deletions

View file

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

View file

@ -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<super::activity::Entity> for Entity {
@ -142,4 +148,16 @@ impl Related<super::attachment::Entity> for Entity {
}
}
impl Related<super::like::Entity> for Entity {
fn to() -> RelationDef {
Relation::Like.def()
}
}
impl Related<super::share::Entity> for Entity {
fn to() -> RelationDef {
Relation::Share.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

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