Billy Chan 9036d27da7
Codegen SQLite (#386)
* Codegen SQLite

* Remove debugging

* Fixup

* Add SQLite "sakila.db" demo [issues]
2021-12-25 11:31:47 +08:00

62 lines
1.4 KiB
Rust

//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "address")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub address_id: i32,
pub address: String,
pub address2: Option<String>,
pub district: String,
pub city_id: i32,
pub postal_code: Option<String>,
pub phone: String,
pub last_update: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::city::Entity",
from = "Column::CityId",
to = "super::city::Column::CityId",
on_update = "Cascade",
on_delete = "NoAction"
)]
City,
#[sea_orm(has_many = "super::customer::Entity")]
Customer,
#[sea_orm(has_many = "super::staff::Entity")]
Staff,
#[sea_orm(has_many = "super::store::Entity")]
Store,
}
impl Related<super::city::Entity> for Entity {
fn to() -> RelationDef {
Relation::City.def()
}
}
impl Related<super::customer::Entity> for Entity {
fn to() -> RelationDef {
Relation::Customer.def()
}
}
impl Related<super::staff::Entity> for Entity {
fn to() -> RelationDef {
Relation::Staff.def()
}
}
impl Related<super::store::Entity> for Entity {
fn to() -> RelationDef {
Relation::Store.def()
}
}
impl ActiveModelBehavior for ActiveModel {}