Start on a new db2 module that uses SeaORM

This commit is contained in:
Antonio Scandurra
2022-11-29 16:49:04 +01:00
parent ac24600a40
commit 11a39226e8
11 changed files with 765 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "projects")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub room_id: i32,
pub host_user_id: i32,
pub host_connection_id: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::room::Entity",
from = "Column::RoomId",
to = "super::room::Column::Id"
)]
Room,
#[sea_orm(has_many = "super::worktree::Entity")]
Worktree,
}
impl Related<super::room::Entity> for Entity {
fn to() -> RelationDef {
Relation::Room.def()
}
}
impl Related<super::worktree::Entity> for Entity {
fn to() -> RelationDef {
Relation::Worktree.def()
}
}
impl ActiveModelBehavior for ActiveModel {}