use crate::{DateTimeUtc, MessageId, RoomId, UserId}; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "room_pin")] pub struct Model { #[sea_orm(primary_key)] pub room: RoomId, #[sea_orm(primary_key)] pub message: MessageId, pub pinned_by: UserId, pub pinned_at: DateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm( belongs_to = "super::room::Entity", from = "Column::Room", to = "super::room::Column::Id" )] Room, #[sea_orm( belongs_to = "super::room_message::Entity", from = "Column::Message", to = "super::room_message::Column::Id" )] Message, } impl Related for Entity { fn to() -> RelationDef { Relation::Room.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Message.def() } } impl ActiveModelBehavior for ActiveModel {}