use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "restaurants")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub area_id: Uuid,
pub name: String,
/// `N123` / `W123` / `R123`; `None` for a hand-dropped pin.
#[sea_orm(unique)]
pub osm_ref: Option<String>,
pub lat: f64,
pub lon: f64,
pub cuisine: Option<String>,
pub address: Option<String>,
pub website: Option<String>,
#[sea_orm(column_type = "Text")]
pub notes: String,
pub archived: bool,
pub added_by: Option<Uuid>,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::areas::Entity",
from = "Column::AreaId",
to = "super::areas::Column::Id",
on_delete = "Cascade"
)]
Areas,
#[sea_orm(has_many = "super::rankings::Entity")]
Rankings,
#[sea_orm(has_many = "super::lunches::Entity")]
Lunches,
}
impl Related<super::areas::Entity> for Entity {
fn to() -> RelationDef {
Relation::Areas.def()
}
}
impl Related<super::rankings::Entity> for Entity {
fn to() -> RelationDef {
Relation::Rankings.def()
}
}
impl Related<super::lunches::Entity> for Entity {
fn to() -> RelationDef {
Relation::Lunches.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.5 KiB · text
History
25c4237