channel.rs

 1use super::{ChannelId, RoomId};
 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    pub room_id: Option<RoomId>,
11}
12
13impl ActiveModelBehavior for ActiveModel {}
14
15#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16pub enum Relation {
17    #[sea_orm(has_one = "super::room::Entity")]
18    Room,
19    #[sea_orm(has_many = "super::channel_member::Entity")]
20    Member,
21}
22
23impl Related<super::channel_member::Entity> for Entity {
24    fn to() -> RelationDef {
25        Relation::Member.def()
26    }
27}
28
29impl Related<super::room::Entity> for Entity {
30    fn to() -> RelationDef {
31        Relation::Room.def()
32    }
33}
34
35// impl Related<super::follower::Entity> for Entity {
36//     fn to() -> RelationDef {
37//         Relation::Follower.def()
38//     }
39// }