pocket-relay-database 0.4.0

Module for isolating the database logic from the Pocket Relay servers
Documentation
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3

use sea_orm::entity::prelude::*;
use serde::Serialize;

use crate::data::user::PlayerRole;

#[derive(Serialize, Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "players")]
pub struct Model {
    /// Unique Identifier for the player
    #[sea_orm(primary_key)]
    pub id: u32,
    /// Email address of the player
    pub email: String,
    /// Display name / Username of the player
    pub display_name: String,
    /// Hashed password which is omitted from serialization
    #[serde(skip)]
    pub password: Option<String>,
    /// The role of the player
    pub role: PlayerRole,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::player_data::Entity")]
    Data,
    #[sea_orm(has_one = "super::galaxy_at_war::Entity")]
    GalaxyAtWar,
}

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

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

impl ActiveModelBehavior for ActiveModel {}