774 B · text History 25c4237
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "areas")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    #[sea_orm(unique)]
    pub name: String,
    pub lat: f64,
    pub lon: f64,
    pub zoom: i32,
    pub created_by: Option<Uuid>,
    pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::restaurants::Entity")]
    Restaurants,
}

impl Related<super::restaurants::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::Restaurants.def()
    }
}

impl ActiveModelBehavior for ActiveModel {}