room.rs

 1use crate::db::{ChannelId, RoomId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Default, Debug, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "rooms")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub id: RoomId,
 9    pub live_kit_room: String,
10    pub channel_id: Option<ChannelId>,
11    pub environment: Option<String>,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16    #[sea_orm(has_many = "super::room_participant::Entity")]
17    RoomParticipant,
18    #[sea_orm(has_many = "super::project::Entity")]
19    Project,
20    #[sea_orm(has_many = "super::follower::Entity")]
21    Follower,
22    #[sea_orm(
23        belongs_to = "super::channel::Entity",
24        from = "Column::ChannelId",
25        to = "super::channel::Column::Id"
26    )]
27    Channel,
28}
29
30impl Related<super::room_participant::Entity> for Entity {
31    fn to() -> RelationDef {
32        Relation::RoomParticipant.def()
33    }
34}
35
36impl Related<super::project::Entity> for Entity {
37    fn to() -> RelationDef {
38        Relation::Project.def()
39    }
40}
41
42impl Related<super::follower::Entity> for Entity {
43    fn to() -> RelationDef {
44        Relation::Follower.def()
45    }
46}
47
48impl Related<super::channel::Entity> for Entity {
49    fn to() -> RelationDef {
50        Relation::Channel.def()
51    }
52}
53
54impl ActiveModelBehavior for ActiveModel {}