53 lines
1.0 KiB
Rust
53 lines
1.0 KiB
Rust
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)]
|
|
pub struct Model {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub cake_id: Option<i32>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
|
pub enum Column {
|
|
Id,
|
|
Name,
|
|
CakeId,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
pub enum PrimaryKey {
|
|
Id,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
pub enum Relation {}
|
|
|
|
impl ColumnTrait for Column {
|
|
type EntityName = Entity;
|
|
|
|
fn def(&self) -> ColumnType {
|
|
match self {
|
|
Self::Id => ColumnType::Integer(None),
|
|
Self::Name => ColumnType::String(None),
|
|
Self::CakeId => ColumnType::Integer(None),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RelationTrait for Relation {
|
|
fn def(&self) -> RelationDef {
|
|
panic!()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|