Skip to content
Clone
a06673b
45 lines 1.3 KB 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 = "chat_messages")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(indexed)]
pub chat_id: Uuid,
pub sender_id: Uuid,
pub body: String,
pub reply_to_message_id: Option<Uuid>,
pub thread_id: Option<Uuid>,
pub is_thread_start: bool,
pub flags: i64,
pub deleted_at: Option<OffsetDateTime>,
pub deleted_by: Option<Uuid>,
pub edited_at: Option<OffsetDateTime>,
#[sea_orm(indexed)]
pub created_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "chat_id", to = "id")]
pub chat: BelongsTo<super::chats::Entity>,
#[sea_orm(belongs_to, from = "sender_id", to = "uid")]
pub sender: BelongsTo<super::super::user::users::Entity>,
#[sea_orm(
self_ref,
relation_enum = "ReplyTo",
relation_reverse = "Replies",
from = "reply_to_message_id",
to = "id"
)]
pub reply_to: HasOne<Entity>,
#[sea_orm(
belongs_to,
relation_enum = "DeletedBy",
from = "deleted_by",
to = "uid"
)]
pub deleted_by_user: BelongsTo<Option<super::super::user::users::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}