33 lines
802 B
Rust
33 lines
802 B
Rust
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "cakes_bakers")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub cake_id: i32,
|
|
#[sea_orm(primary_key)]
|
|
pub baker_id: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::cake::Entity",
|
|
from = "Column::CakeId",
|
|
to = "super::cake::Column::Id",
|
|
on_update = "Cascade",
|
|
on_delete = "Cascade"
|
|
)]
|
|
Cake,
|
|
#[sea_orm(
|
|
belongs_to = "super::baker::Entity",
|
|
from = "Column::BakerId",
|
|
to = "super::baker::Column::Id",
|
|
on_update = "Cascade",
|
|
on_delete = "Cascade"
|
|
)]
|
|
Baker,
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|