rowt/src/models/trip.rs
2023-02-09 12:16:04 +01:00

59 lines
1.4 KiB
Rust

//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "trip")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub day: String,
#[sea_orm(primary_key, auto_increment = false)]
pub user_id: i32,
pub cox_id: Option<i32>,
pub begin: Option<String>,
pub created: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::day::Entity",
from = "Column::Day",
to = "super::day::Column::Day",
on_update = "NoAction",
on_delete = "NoAction"
)]
Day,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::CoxId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Cox,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
User,
}
impl Related<super::day::Entity> for Entity {
fn to() -> RelationDef {
Relation::Day.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}