Go back to a compiling state, panicking on unimplemented db methods

This commit is contained in:
Antonio Scandurra 2022-12-01 15:13:34 +01:00
parent d2385bd6a0
commit db1d93576f
4 changed files with 1240 additions and 51 deletions

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,12 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation { pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::HostUserId",
to = "super::user::Column::Id"
)]
HostUser,
#[sea_orm( #[sea_orm(
belongs_to = "super::room::Entity", belongs_to = "super::room::Entity",
from = "Column::RoomId", from = "Column::RoomId",
@ -23,6 +29,12 @@ pub enum Relation {
Worktree, Worktree,
} }
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::HostUser.def()
}
}
impl Related<super::room::Entity> for Entity { impl Related<super::room::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::Room.def() Relation::Room.def()

View file

@ -1,4 +1,4 @@
use super::{ProjectCollaboratorId, ProjectId, UserId}; use super::{ProjectCollaboratorId, ProjectId, ReplicaId, UserId};
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
@ -9,7 +9,7 @@ pub struct Model {
pub project_id: ProjectId, pub project_id: ProjectId,
pub connection_id: i32, pub connection_id: i32,
pub user_id: UserId, pub user_id: UserId,
pub replica_id: i32, pub replica_id: ReplicaId,
pub is_host: bool, pub is_host: bool,
} }

View file

@ -24,6 +24,8 @@ pub enum Relation {
AccessToken, AccessToken,
#[sea_orm(has_one = "super::room_participant::Entity")] #[sea_orm(has_one = "super::room_participant::Entity")]
RoomParticipant, RoomParticipant,
#[sea_orm(has_many = "super::project::Entity")]
HostedProjects,
} }
impl Related<super::access_token::Entity> for Entity { impl Related<super::access_token::Entity> for Entity {
@ -38,4 +40,10 @@ impl Related<super::room_participant::Entity> for Entity {
} }
} }
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::HostedProjects.def()
}
}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}