27 lines
748 B
Rust
27 lines
748 B
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Deserialize, Serialize, utoipa::ToSchema)]
|
|
#[sea_orm(table_name = "Owners")]
|
|
#[schema(title="Owner", as=entities::Owner)]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = true)]
|
|
pub id: u32,
|
|
pub first_name: String,
|
|
pub last_name: String,
|
|
pub contact: String
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(has_many = "super::book_instance::Entity")]
|
|
BookInstance
|
|
}
|
|
|
|
impl Related<super::book_instance::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::BookInstance.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|