finish backend tests of new db layout

This commit is contained in:
2023-10-29 20:41:30 +01:00
parent 09075989e3
commit 1d7f95e522
5 changed files with 216 additions and 106 deletions

View File

@ -11,7 +11,7 @@ use rocket::{
Request,
};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::{log::Log, tripdetails::TripDetails, Day};
@ -103,6 +103,21 @@ WHERE id like ?
.ok()
}
pub async fn find_by_id_tx(db: &mut Transaction<'_, Sqlite>, id: i32) -> Option<Self> {
sqlx::query_as!(
Self,
"
SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access, is_tech
FROM user
WHERE id like ?
",
id
)
.fetch_one(db)
.await
.ok()
}
pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
sqlx::query_as!(
Self,