kellnr_entity/
auth_token.rs1use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "auth_token")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: i64,
10 #[sea_orm(column_type = "Text")]
11 pub name: String,
12 #[sea_orm(column_type = "Text", unique)]
13 pub token: String,
14 pub user_fk: i64,
15 #[sea_orm(column_type = "Text", nullable)]
16 pub created: Option<String>,
17 #[sea_orm(column_type = "Text", nullable)]
18 pub last_used: Option<String>,
19}
20
21#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
22pub enum Relation {
23 #[sea_orm(
24 belongs_to = "super::user::Entity",
25 from = "Column::UserFk",
26 to = "super::user::Column::Id",
27 on_update = "NoAction",
28 on_delete = "Cascade"
29 )]
30 User,
31}
32
33impl Related<super::user::Entity> for Entity {
34 fn to() -> RelationDef {
35 Relation::User.def()
36 }
37}
38
39impl ActiveModelBehavior for ActiveModel {}