46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
//! `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 = "attachment")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub message_id: Uuid,
|
|
pub filename: String,
|
|
pub file_size: i32,
|
|
pub mime_type: String,
|
|
pub created_at: DateTime,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::message::Entity",
|
|
from = "Column::MessageId",
|
|
to = "super::message::Column::Id",
|
|
on_update = "NoAction",
|
|
on_delete = "Cascade"
|
|
)]
|
|
Message,
|
|
}
|
|
|
|
impl Related<super::message::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Message.def()
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl ActiveModelBehavior for ActiveModel {
|
|
fn new() -> Self {
|
|
Self {
|
|
id: Set(Uuid::new_v4()),
|
|
..ActiveModelTrait::default()
|
|
}
|
|
}
|
|
}
|