Had to make fields Optional if they're Nullable..
Makes sense. Gonna need another type for pre-commited User objects though.
This commit is contained in:
parent
6cb7b5affa
commit
3606cdf4ee
|
@ -1,16 +1,26 @@
|
|||
use chrono::{
|
||||
NaiveDateTime,
|
||||
};
|
||||
use diesel::prelude::*;
|
||||
use diesel::PgConnection;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
#[derive(Queryable, Debug)]
|
||||
pub struct User {
|
||||
pub id: Option<i32>,
|
||||
pub username: String,
|
||||
pub is_active: bool,
|
||||
pub id: i32,
|
||||
pub username: Option<String>,
|
||||
pub is_active: Option<bool>,
|
||||
pub created_at: Option<NaiveDateTime>,
|
||||
pub updated_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn get_with_username(conn: &PgConnection, name: String) -> QueryResult<User> {
|
||||
use crate::schema::users::dsl::{ username, users };
|
||||
users.filter(username.eq(&name)).first::<User>(conn)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Queryable)]
|
||||
pub struct Token {
|
||||
pub id: Option<i32>,
|
||||
|
|
Loading…
Reference in New Issue