use super::*;
#[derive(Serialize, Queryable, Selectable)]
#[diesel(table_name = schema::user)]
pub struct User {
pub id: i32,
pub email: String,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub birthday: Option<time::Date>,
pub created: time::PrimitiveDateTime,
pub verified: bool,
}
pub type Response = Vec<User>;
#[get("")]
pub async fn route(db: web::Data<Database>) -> impl Responder {
let response: Response = web::block(move || {
let mut conn = db.get_conn();
conn.transaction(|conn| {
schema::user::table
.select(User::as_select())
.load::<User>(conn)
})
.unwrap()
})
.await
.unwrap();
web::Json(response)
}