Add all connectors
This commit is contained in:
moneymgr_backend
1
moneymgr_backend/src/models/mod.rs
Normal file
1
moneymgr_backend/src/models/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod users;
|
29
moneymgr_backend/src/models/users.rs
Normal file
29
moneymgr_backend/src/models/users.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use crate::schema::*;
|
||||
use diesel::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
pub struct UserID(pub i32);
|
||||
|
||||
#[derive(Queryable, Debug, Clone, serde::Serialize)]
|
||||
pub struct User {
|
||||
id: i32,
|
||||
pub mail: String,
|
||||
pub name: String,
|
||||
pub time_create: i64,
|
||||
pub time_update: i64,
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn id(&self) -> UserID {
|
||||
UserID(self.id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[diesel(table_name = users)]
|
||||
pub struct NewUser<'a> {
|
||||
pub time_create: i64,
|
||||
pub time_update: i64,
|
||||
pub name: &'a str,
|
||||
pub mail: &'a str,
|
||||
}
|
Reference in New Issue
Block a user