47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "active_enum")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub category: Option<Category>,
|
|
pub color: Option<Color>,
|
|
pub tea: Option<Tea>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|
|
|
|
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)]
|
|
#[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
|
|
pub enum Category {
|
|
#[sea_orm(string_value = "B")]
|
|
Big,
|
|
#[sea_orm(string_value = "S")]
|
|
Small,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)]
|
|
#[sea_orm(rs_type = "i32", db_type = r#"Integer"#)]
|
|
pub enum Color {
|
|
#[sea_orm(num_value = 0)]
|
|
Black,
|
|
#[sea_orm(num_value = 1)]
|
|
White,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)]
|
|
#[sea_orm(
|
|
rs_type = "String",
|
|
db_type = r#"Enum("tea".to_owned(), vec!["EverydayTea".to_owned(), "BreakfastTea".to_owned()])"#
|
|
)]
|
|
pub enum Tea {
|
|
#[sea_orm(string_value = "EverydayTea")]
|
|
EverydayTea,
|
|
#[sea_orm(string_value = "BreakfastTea")]
|
|
BreakfastTea,
|
|
}
|