discord/src/entity/channels.rs
2026-02-13 17:45:29 +01:00

32 lines
769 B
Rust

use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "channels")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: Uuid,
pub guild_id: Uuid,
pub name: String,
pub kind: String,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::guilds::Entity",
from = "Column::GuildId",
to = "super::guilds::Column::Id"
)]
Guilds,
#[sea_orm(has_many = "super::messages::Entity")]
Messages,
}
impl Related<super::guilds::Entity> for Entity {
fn to() -> RelationDef {
Relation::Guilds.def()
}
}
impl ActiveModelBehavior for ActiveModel {}