room_participant.rs

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