project.rs

 1use super::{ProjectId, RoomId, UserId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "projects")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub id: ProjectId,
 9    pub room_id: RoomId,
10    pub host_user_id: UserId,
11    pub host_connection_id: i32,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16    #[sea_orm(
17        belongs_to = "super::user::Entity",
18        from = "Column::HostUserId",
19        to = "super::user::Column::Id"
20    )]
21    HostUser,
22    #[sea_orm(
23        belongs_to = "super::room::Entity",
24        from = "Column::RoomId",
25        to = "super::room::Column::Id"
26    )]
27    Room,
28    #[sea_orm(has_many = "super::worktree::Entity")]
29    Worktree,
30}
31
32impl Related<super::user::Entity> for Entity {
33    fn to() -> RelationDef {
34        Relation::HostUser.def()
35    }
36}
37
38impl Related<super::room::Entity> for Entity {
39    fn to() -> RelationDef {
40        Relation::Room.def()
41    }
42}
43
44impl Related<super::worktree::Entity> for Entity {
45    fn to() -> RelationDef {
46        Relation::Worktree.def()
47    }
48}
49
50impl ActiveModelBehavior for ActiveModel {}