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

43 lines
1.0 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 = "city")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub city_id: i32,
pub city: String,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")]
pub country_id: String,
pub last_update: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::country::Entity",
from = "Column::CountryId",
to = "super::country::Column::CountryId",
on_update = "Cascade",
on_delete = "NoAction"
)]
Country,
#[sea_orm(has_many = "super::address::Entity")]
Address,
}
impl Related<super::country::Entity> for Entity {
fn to() -> RelationDef {
Relation::Country.def()
}
}
impl Related<super::address::Entity> for Entity {
fn to() -> RelationDef {
Relation::Address.def()
}
}
impl ActiveModelBehavior for ActiveModel {}