channel.rs

 1use super::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_many = "super::channel_member::Entity")]
19    Member,
20}
21
22impl Related<super::channel_member::Entity> for Entity {
23    fn to() -> RelationDef {
24        Relation::Member.def()
25    }
26}
27
28impl Related<super::room::Entity> for Entity {
29    fn to() -> RelationDef {
30        Relation::Room.def()
31    }
32}
33
34// impl Related<super::follower::Entity> for Entity {
35//     fn to() -> RelationDef {
36//         Relation::Follower.def()
37//     }
38// }