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