use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub topic_id: Uuid,
pub user_id: Uuid,
/// 1-based sequence within the topic (the topic's opening post is 1).
pub post_number: i32,
/// Raw markdown as authored.
#[sea_orm(column_type = "Text")]
pub raw: String,
/// Rendered + sanitized HTML, cached at write time.
#[sea_orm(column_type = "Text")]
pub cooked: String,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
/// When the post was last edited (None = never edited).
pub edited_at: Option<DateTimeWithTimeZone>,
/// Number of edits since creation (0 = original only).
pub edit_count: i32,
pub last_editor_id: Option<Uuid>,
/// Soft-delete tombstone — set instead of removing the row so post numbers
/// and `#post-N` references stay stable.
pub deleted_at: Option<DateTimeWithTimeZone>,
pub deleted_by_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::topics::Entity",
from = "Column::TopicId",
to = "super::topics::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Topics,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::UserId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Users,
}
impl Related<super::topics::Entity> for Entity {
fn to() -> RelationDef {
Relation::Topics.def()
}
}
impl Related<super::users::Entity> for Entity {
fn to() -> RelationDef {
Relation::Users.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.9 KiB · text
History
2264215