42 lines
1 KiB
Rust
42 lines
1 KiB
Rust
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
|
#[sea_orm(table_name = "ingredient")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i64,
|
|
pub household: Uuid,
|
|
pub name: String,
|
|
pub unit: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::household::Entity",
|
|
from = "Column::Household",
|
|
to = "super::household::Column::Id",
|
|
on_update = "Restrict",
|
|
on_delete = "Restrict"
|
|
)]
|
|
Household,
|
|
}
|
|
|
|
impl Related<super::household::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Household.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::recipe::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
super::recipe_ingerdients::Relation::Recipe.def()
|
|
}
|
|
fn via() -> Option<RelationDef> {
|
|
Some(super::recipe_ingerdients::Relation::Ingredient.def().rev())
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|