init
This commit is contained in:
commit
c7a592933e
32 changed files with 7871 additions and 0 deletions
44
src/entity/invites.rs
Normal file
44
src/entity/invites.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
||||
#[sea_orm(table_name = "invites")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub code: String,
|
||||
pub guild_id: Uuid,
|
||||
pub created_by_user_id: Uuid,
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub expires_at: Option<DateTimeWithTimeZone>,
|
||||
pub max_uses: Option<i32>,
|
||||
pub use_count: i32,
|
||||
}
|
||||
|
||||
#[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(
|
||||
belongs_to = "super::users::Entity",
|
||||
from = "Column::CreatedByUserId",
|
||||
to = "super::users::Column::Id"
|
||||
)]
|
||||
Users,
|
||||
}
|
||||
|
||||
impl Related<super::guilds::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Guilds.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::users::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Users.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue