Fixed an error message that just said "deez" to something bettar

This commit is contained in:
LinlyBoi
2022-12-31 23:18:02 +02:00
parent ec7a79b8b6
commit 9f18b593f9

View File

@@ -3,7 +3,7 @@ use actix_web::{get, web, HttpResponse, Responder};
use async_trait::async_trait; use async_trait::async_trait;
use chrono::NaiveDate; use chrono::NaiveDate;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{types::Json, PgPool}; use sqlx::PgPool;
#[derive(Serialize, Deserialize, Debug, Clone, sqlx::FromRow)] #[derive(Serialize, Deserialize, Debug, Clone, sqlx::FromRow)]
pub struct Driver { pub struct Driver {
@@ -14,10 +14,6 @@ pub struct Driver {
pub birthdate: NaiveDate, pub birthdate: NaiveDate,
} }
pub struct Row {
pub id: i32,
pub person: Json<Driver>,
}
#[async_trait] #[async_trait]
impl SqlStruct<i32> for Driver { impl SqlStruct<i32> for Driver {
async fn add(&self, pool: &PgPool) -> anyhow::Result<i32> { async fn add(&self, pool: &PgPool) -> anyhow::Result<i32> {
@@ -43,7 +39,7 @@ pub async fn list_all(db_pool: web::Data<PgPool>) -> impl Responder {
let drivers = sqlx::query_as!(Driver, "SELECT * FROM drivers") let drivers = sqlx::query_as!(Driver, "SELECT * FROM drivers")
.fetch_all(db_pool.get_ref()) .fetch_all(db_pool.get_ref())
.await .await
.expect("deez"); .expect("Could not fetch anything from the DB D:");
HttpResponse::Ok() HttpResponse::Ok()
.content_type("application/json") .content_type("application/json")
.json(drivers) .json(drivers)