use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
/// One trip out to lunch — the history the suggester steers away from.
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "lunches")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub restaurant_id: Uuid,
pub went_on: Date,
pub logged_by: Option<Uuid>,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::restaurants::Entity",
from = "Column::RestaurantId",
to = "super::restaurants::Column::Id",
on_delete = "Cascade"
)]
Restaurants,
#[sea_orm(has_many = "super::lunch_attendees::Entity")]
LunchAttendees,
}
impl Related<super::restaurants::Entity> for Entity {
fn to() -> RelationDef {
Relation::Restaurants.def()
}
}
impl Related<super::lunch_attendees::Entity> for Entity {
fn to() -> RelationDef {
Relation::LunchAttendees.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/fieri-forever
the flavortown lunch engine
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
1.1 KiB · text
History
25c4237