1use crate::db::ChannelId;
2use sea_orm::entity::prelude::*;
3
4#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
5#[sea_orm(table_name = "channels")]
6pub struct Model {
7 #[sea_orm(primary_key)]
8 pub id: ChannelId,
9 pub name: String,
10}
11
12impl ActiveModelBehavior for ActiveModel {}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(has_one = "super::room::Entity")]
17 Room,
18 #[sea_orm(has_one = "super::buffer::Entity")]
19 Buffer,
20 #[sea_orm(has_many = "super::channel_member::Entity")]
21 Member,
22 #[sea_orm(has_many = "super::channel_buffer_collaborator::Entity")]
23 BufferCollaborators,
24 #[sea_orm(has_many = "super::channel_chat_participant::Entity")]
25 ChatParticipants,
26}
27
28impl Related<super::channel_member::Entity> for Entity {
29 fn to() -> RelationDef {
30 Relation::Member.def()
31 }
32}
33
34impl Related<super::room::Entity> for Entity {
35 fn to() -> RelationDef {
36 Relation::Room.def()
37 }
38}
39
40impl Related<super::buffer::Entity> for Entity {
41 fn to() -> RelationDef {
42 Relation::Buffer.def()
43 }
44}
45
46impl Related<super::channel_buffer_collaborator::Entity> for Entity {
47 fn to() -> RelationDef {
48 Relation::BufferCollaborators.def()
49 }
50}
51
52impl Related<super::channel_chat_participant::Entity> for Entity {
53 fn to() -> RelationDef {
54 Relation::ChatParticipants.def()
55 }
56}