//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 use sea_orm::entity::prelude::*; #[derive(Copy, Clone, Default, Debug, DeriveEntity)] pub struct Entity; impl EntityName for Entity { fn table_name(&self) -> &str { "fruit" } } #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] pub struct Model { pub id: i32, pub name: String, pub cake_id: Option , } #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] pub enum Column { Id, Name, CakeId, } #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] pub enum PrimaryKey { Id, } impl PrimaryKeyTrait for PrimaryKey { type ValueType = i32; fn auto_increment() -> bool { true } } #[derive(Copy, Clone, Debug, EnumIter)] pub enum Relation { Cake, Vendor, } impl ColumnTrait for Column { type EntityName = Entity; fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::Integer.def(), Self::Name => ColumnType::string(Some(255u32)).def(), Self::CakeId => ColumnType::Integer.def().null(), } } } impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { Self::Cake => Entity::belongs_to(super::cake::Entity) .from(Column::CakeId) .to(super::cake::Column::Id) .into(), Self::Vendor => Entity::has_many(super::vendor::Entity).into(), } } } impl Related for Entity { fn to() -> RelationDef { Relation::Cake.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Vendor.def() } } impl ActiveModelBehavior for ActiveModel {}