use crate::db::UserId; use sea_orm::entity::prelude::*; use serde::Serialize; /// A user model. #[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel, Serialize)] #[sea_orm(table_name = "users")] pub struct Model { #[sea_orm(primary_key)] pub id: UserId, pub admin: bool, pub connected_once: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm(has_one = "super::room_participant::Entity")] RoomParticipant, #[sea_orm(has_many = "super::project::Entity")] HostedProjects, #[sea_orm(has_many = "super::channel_member::Entity")] ChannelMemberships, } impl Related for Entity { fn to() -> RelationDef { Relation::RoomParticipant.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::HostedProjects.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::ChannelMemberships.def() } } impl ActiveModelBehavior for ActiveModel {}