39 lines
971 B
Rust
39 lines
971 B
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "user")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
#[sea_orm(unique)]
|
|
pub username: Option<String>,
|
|
#[serde(skip_serializing)]
|
|
pub password_hash: Option<String>,
|
|
pub is_admin: bool,
|
|
#[sea_orm(unique)]
|
|
pub email: Option<String>,
|
|
#[sea_orm(unique)]
|
|
#[serde(skip_serializing)]
|
|
pub google_id: Option<String>,
|
|
pub family_id: Option<i32>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::family::Entity",
|
|
from = "Column::FamilyId",
|
|
to = "super::family::Column::Id"
|
|
)]
|
|
Family,
|
|
}
|
|
|
|
impl Related<super::family::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Family.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|