trifid/trifid-api/src/models.rs

62 lines
1.7 KiB
Rust
Raw Normal View History

2023-11-19 16:31:30 +00:00
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
2023-11-21 01:07:02 +00:00
use std::time::SystemTime;
2023-11-19 15:49:08 +00:00
2023-11-21 01:07:02 +00:00
#[derive(Queryable, Selectable, Insertable, Identifiable, Debug, PartialEq, Clone)]
2023-11-19 15:49:08 +00:00
#[diesel(table_name = crate::schema::users)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct User {
pub id: String,
2023-11-21 01:07:02 +00:00
pub email: String,
2023-11-19 16:31:30 +00:00
}
2023-11-21 01:07:02 +00:00
#[derive(
Queryable, Selectable, Insertable, Identifiable, Associations, Debug, PartialEq, Clone,
)]
2023-11-19 16:31:30 +00:00
#[diesel(belongs_to(User))]
#[diesel(table_name = crate::schema::magic_links)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct MagicLink {
pub id: String,
pub user_id: String,
2023-11-21 01:07:02 +00:00
pub expires: SystemTime,
2023-11-20 01:58:46 +00:00
}
2023-11-21 01:07:02 +00:00
#[derive(
Queryable, Selectable, Insertable, Identifiable, Associations, Debug, PartialEq, Clone,
)]
2023-11-20 01:58:46 +00:00
#[diesel(belongs_to(User))]
#[diesel(table_name = crate::schema::session_tokens)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct SessionToken {
pub id: String,
pub user_id: String,
2023-11-21 01:07:02 +00:00
pub expires: SystemTime,
}
#[derive(
Queryable, Selectable, Insertable, Identifiable, Associations, Debug, PartialEq, Clone,
)]
#[diesel(belongs_to(User))]
#[diesel(table_name = crate::schema::totp_authenticators)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct TotpAuthenticator {
pub id: String,
pub user_id: String,
pub secret: String,
pub verified: bool,
2023-11-23 03:50:20 +00:00
pub name: String,
pub created_at: SystemTime,
pub last_seen_at: SystemTime
2023-11-21 01:07:02 +00:00
}
2023-11-22 15:59:21 +00:00
#[derive(
Queryable, Selectable, Insertable, Identifiable, Associations, Debug, PartialEq, Clone,
)]
#[diesel(belongs_to(User))]
#[diesel(table_name = crate::schema::auth_tokens)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct AuthToken {
pub id: String,
pub user_id: String,
pub expires: SystemTime,
}