
* Move all sea_orm tables into a 'tables' module * Move TestDb into its own file * Move id types into their own module
29 lines
682 B
Rust
29 lines
682 B
Rust
use crate::db::{AccessTokenId, UserId};
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "access_tokens")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: AccessTokenId,
|
|
pub user_id: UserId,
|
|
pub hash: String,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::user::Entity",
|
|
from = "Column::UserId",
|
|
to = "super::user::Column::Id"
|
|
)]
|
|
User,
|
|
}
|
|
|
|
impl Related<super::user::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::User.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|