Skip to content
Clone
a06673b
30 lines 997 B Rust
use sea_orm::entity::prelude::*;
use time::OffsetDateTime;
use uuid::Uuid;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "thread")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub chat_id: Uuid,
#[sea_orm(primary_key, auto_increment = false)]
pub root_message_id: Uuid,
#[sea_orm(default_value = "0")]
pub reply_count: i32,
pub last_reply_at: Option<OffsetDateTime>,
pub last_reply_by: Option<Uuid>,
#[sea_orm(belongs_to, from = "chat_id", to = "id")]
pub chat: BelongsTo<super::chats::Entity>,
#[sea_orm(belongs_to, from = "root_message_id", to = "id")]
pub root_message: BelongsTo<super::chat_messages::Entity>,
#[sea_orm(
belongs_to,
relation_enum = "LastReplyBy",
from = "last_reply_by",
to = "uid"
)]
pub last_reply_user: BelongsTo<Option<super::super::user::users::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}