init
This commit is contained in:
+7
-28
@@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
|
||||
use sea_orm::prelude::async_trait::async_trait;
|
||||
use sea_orm::Set;
|
||||
|
||||
#[sea_orm::model]
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "server")]
|
||||
pub struct Model {
|
||||
@@ -15,34 +16,12 @@ pub struct Model {
|
||||
pub updated_at: DateTimeUtc,
|
||||
pub is_default: bool,
|
||||
pub owner_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::category::Entity")]
|
||||
Category,
|
||||
#[sea_orm(has_many = "super::channel::Entity")]
|
||||
Channel,
|
||||
#[sea_orm(has_many = "super::server_user::Entity")]
|
||||
ServerUser,
|
||||
}
|
||||
|
||||
impl Related<super::category::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Category.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::channel::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Channel.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::server_user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::ServerUser.def()
|
||||
}
|
||||
#[sea_orm(has_many)]
|
||||
pub categories: HasMany<super::category::Entity>,
|
||||
#[sea_orm(has_many)]
|
||||
pub channels: HasMany<super::channel::Entity>,
|
||||
#[sea_orm(has_many)]
|
||||
pub server_users: HasMany<super::server_user::Entity>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
Reference in New Issue
Block a user