deepwell 2024.5.12

DEEPWELL - Wikijump API provider and database manager
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "message")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub internal_id: i64,
    #[sea_orm(column_type = "Text")]
    pub record_id: String,
    pub user_id: i64,
    pub flag_read: bool,
    pub flag_inbox: bool,
    pub flag_outbox: bool,
    pub flag_self: bool,
    pub flag_trash: bool,
    pub flag_star: bool,
    pub tags: Vec<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::message_record::Entity",
        from = "Column::RecordId",
        to = "super::message_record::Column::ExternalId",
        on_update = "NoAction",
        on_delete = "NoAction"
    )]
    MessageRecord,
    #[sea_orm(has_many = "super::message_report::Entity")]
    MessageReport,
    #[sea_orm(
        belongs_to = "super::user::Entity",
        from = "Column::UserId",
        to = "super::user::Column::UserId",
        on_update = "NoAction",
        on_delete = "NoAction"
    )]
    User,
}

impl Related<super::message_record::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::MessageRecord.def()
    }
}

impl Related<super::message_report::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::MessageReport.def()
    }
}

impl Related<super::user::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::User.def()
    }
}

impl Related<super::site::Entity> for Entity {
    fn to() -> RelationDef {
        super::message_report::Relation::Site.def()
    }
    fn via() -> Option<RelationDef> {
        Some(super::message_report::Relation::Message.def().rev())
    }
}

impl ActiveModelBehavior for ActiveModel {}