801 B · text History 7a00c02
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "lunch_attendees")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub lunch_id: Uuid,
    #[sea_orm(primary_key, auto_increment = false)]
    pub user_id: Uuid,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::lunches::Entity",
        from = "Column::LunchId",
        to = "super::lunches::Column::Id",
        on_delete = "Cascade"
    )]
    Lunches,
}

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

impl ActiveModelBehavior for ActiveModel {}