Add user follow relation

This commit is contained in:
aprilthepink 2024-05-05 16:26:48 +02:00
parent 9acf6578bf
commit 468371d43d
5 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,38 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.10
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "follow_relation")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub followee_id: String,
pub follower_id: String,
pub followee_host: Option<String>,
pub follower_host: Option<String>,
pub followee_inbox: Option<String>,
pub follower_inbox: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FollowerId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FolloweeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -4,3 +4,4 @@ pub mod prelude;
pub mod post;
pub mod user;
pub mod follow_relation;

View file

@ -1,4 +1,5 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.10
pub use super::follow_relation::Entity as FollowRelation;
pub use super::post::Entity as Post;
pub use super::user::Entity as User;