//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19 use sea_orm::entity::prelude::*; use sea_orm::prelude::async_trait::async_trait; use sea_orm::Set; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "message")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub channel_id: Uuid, pub user_id: Uuid, #[sea_orm(column_type = "Text")] pub content: String, pub created_at: DateTime, pub edited_at: Option, pub reply_to_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm(has_many = "super::attachment::Entity")] Attachment, #[sea_orm( belongs_to = "super::channel::Entity", from = "Column::ChannelId", to = "super::channel::Column::Id", on_update = "NoAction", on_delete = "Cascade" )] Channel, #[sea_orm( belongs_to = "Entity", from = "Column::ReplyToId", to = "Column::Id", on_update = "NoAction", on_delete = "SetNull" )] SelfRef, #[sea_orm( belongs_to = "super::user::Entity", from = "Column::UserId", to = "super::user::Column::Id", on_update = "NoAction", on_delete = "Cascade" )] User, } impl Related for Entity { fn to() -> RelationDef { Relation::Attachment.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Channel.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::User.def() } } #[async_trait] impl ActiveModelBehavior for ActiveModel { fn new() -> Self { Self { id: Set(Uuid::new_v4()), ..ActiveModelTrait::default() } } }