45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19
|
|
|
|
use sea_orm::Set;
|
|
use sea_orm::entity::prelude::*;
|
|
use sea_orm::prelude::async_trait::async_trait;
|
|
|
|
#[sea_orm::model]
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
|
#[sea_orm(table_name = "server_user")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key, auto_increment = false)]
|
|
pub id: Uuid,
|
|
pub server_id: Uuid,
|
|
pub user_id: Uuid,
|
|
pub username: Option<String>,
|
|
pub joined_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
#[sea_orm(
|
|
belongs_to,
|
|
from = "server_id",
|
|
to = "id",
|
|
on_update = "NoAction",
|
|
on_delete = "Cascade"
|
|
)]
|
|
pub server: HasOne<super::server::Entity>,
|
|
#[sea_orm(
|
|
belongs_to,
|
|
from = "user_id",
|
|
to = "id",
|
|
on_update = "NoAction",
|
|
on_delete = "Cascade"
|
|
)]
|
|
pub user: HasOne<super::user::Entity>,
|
|
}
|
|
|
|
#[async_trait]
|
|
impl ActiveModelBehavior for ActiveModel {
|
|
fn new() -> Self {
|
|
Self {
|
|
id: Set(Uuid::new_v4()),
|
|
..ActiveModelTrait::default()
|
|
}
|
|
}
|
|
}
|