shared_thread.rs

 1use crate::db::{SharedThreadId, UserId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "shared_threads")]
 6pub struct Model {
 7    #[sea_orm(primary_key, auto_increment = false)]
 8    pub id: SharedThreadId,
 9    pub user_id: UserId,
10    pub title: String,
11    pub data: Vec<u8>,
12    pub created_at: DateTime,
13    pub updated_at: DateTime,
14}
15
16#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
17pub enum Relation {
18    #[sea_orm(
19        belongs_to = "super::user::Entity",
20        from = "Column::UserId",
21        to = "super::user::Column::Id"
22    )]
23    User,
24}
25
26impl Related<super::user::Entity> for Entity {
27    fn to() -> RelationDef {
28        Relation::User.def()
29    }
30}
31
32impl ActiveModelBehavior for ActiveModel {}