Skip to content
Clone

feat(db): add live db entities (meets, meet_participants) under lib/db/live

zhenyi committed
parent 60c8a27 commit 47fc7c0 Browse files

3 files changed

+81 −0

File tree 3
Added lib/db/live/meet_participants.rs View lib/db/live/meet_participants.rs
@@ -0,0 +1,40 @@
1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3use time::OffsetDateTime;
4use uuid::Uuid;
5
6#[derive(
7 Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
8)]
9#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
10pub enum LeaveReason {
11 NotLeft = 0,
12 Left = 1,
13 Removed = 2,
14 RoomEnded = 3,
15 NetworkDrop = 4,
16 #[default]
17 Kicked = 5,
18}
19
20#[sea_orm::model]
21#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
22#[sea_orm(table_name = "meet_participants")]
23pub struct Model {
24 #[sea_orm(primary_key, auto_increment = false)]
25 pub id: Uuid,
26 #[sea_orm(indexed)]
27 pub meet_id: Uuid,
28 #[sea_orm(indexed)]
29 pub user_id: Uuid,
30 pub joined_at: OffsetDateTime,
31 pub left_at: Option<OffsetDateTime>,
32 pub leave_reason: Option<LeaveReason>,
33 pub connection_id: Option<String>,
34 #[sea_orm(belongs_to, from = "meet_id", to = "id")]
35 pub meet: BelongsTo<super::meets::Entity>,
36 #[sea_orm(belongs_to, from = "user_id", to = "uid")]
37 pub user: BelongsTo<super::super::user::users::Entity>,
38}
39
40impl ActiveModelBehavior for ActiveModel {}
Added lib/db/live/meets.rs View lib/db/live/meets.rs
@@ -0,0 +1,39 @@
1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3use time::OffsetDateTime;
4use uuid::Uuid;
5
6#[derive(
7 Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
8)]
9#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
10pub enum MeetStatus {
11 #[default]
12 Pending = 0,
13 Active = 1,
14 Ended = 2,
15}
16
17#[sea_orm::model]
18#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
19#[sea_orm(table_name = "meet")]
20pub struct Model {
21 #[sea_orm(primary_key, auto_increment = false)]
22 pub id: Uuid,
23 #[sea_orm(indexed)]
24 pub channel_id: Uuid,
25 pub room_name: String,
26 pub status: MeetStatus,
27 #[sea_orm(indexed)]
28 pub created_by: Uuid,
29 pub started_at: Option<OffsetDateTime>,
30 pub ended_at: Option<OffsetDateTime>,
31 pub created_at: OffsetDateTime,
32 pub updated_at: Option<OffsetDateTime>,
33 #[sea_orm(belongs_to, from = "channel_id", to = "id")]
34 pub channel: BelongsTo<super::super::channel::channels::Entity>,
35 #[sea_orm(belongs_to, from = "created_by", to = "uid")]
36 pub creator: BelongsTo<super::super::user::users::Entity>,
37}
38
39impl ActiveModelBehavior for ActiveModel {}
Added lib/db/live/mod.rs View lib/db/live/mod.rs
@@ -0,0 +1,2 @@
1pub mod meet_participants;
2pub mod meets;