1use crate::db::{ChannelId, MessageId, UserId};
2use sea_orm::entity::prelude::*;
3
4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
5#[sea_orm(table_name = "observed_channel_messages")]
6pub struct Model {
7 #[sea_orm(primary_key)]
8 pub user_id: UserId,
9 pub channel_id: ChannelId,
10 pub channel_message_id: MessageId,
11}
12
13#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
14pub enum Relation {
15 #[sea_orm(
16 belongs_to = "super::channel::Entity",
17 from = "Column::ChannelId",
18 to = "super::channel::Column::Id"
19 )]
20 Channel,
21 #[sea_orm(
22 belongs_to = "super::user::Entity",
23 from = "Column::UserId",
24 to = "super::user::Column::Id"
25 )]
26 User,
27}
28
29impl Related<super::channel::Entity> for Entity {
30 fn to() -> RelationDef {
31 Relation::Channel.def()
32 }
33}
34
35impl Related<super::user::Entity> for Entity {
36 fn to() -> RelationDef {
37 Relation::User.def()
38 }
39}
40
41impl ActiveModelBehavior for ActiveModel {}