use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "games")] pub struct Model { #[sea_orm(primary_key)] pub id: i32, pub creation_time: i64, // seconds since unix epoch pub guid: i64, pub map: String, pub mode: GameMode, pub visibility: MapVisibility, pub auto_heal: bool, pub variant: GameType, pub is_complete: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm(has_many = "super::multiplayer_game_player::Entity")] Player, } impl Related for Entity { fn to() -> RelationDef { Relation::Player.def() } } impl ActiveModelBehavior for ActiveModel {} #[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")] pub enum GameMode { BattleArena, SuddenDeath, Pit, TestMode, SinglePlayer, TeamDeathmatch, Campaign, } #[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")] pub enum MapVisibility { Good, Poor, Bad, } #[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")] pub enum GameType { Standard, Ranked, Custom, }