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

@@ -1,6 +1,6 @@
use chrono::{DateTime, Local, NaiveDateTime, TimeZone, Utc};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct Log {
@@ -15,6 +15,12 @@ impl Log {
.await
.is_ok()
}
pub async fn create_with_tx(db: &mut Transaction<'_, Sqlite>, msg: String) -> bool {
sqlx::query!("INSERT INTO log(msg) VALUES (?)", msg,)
.execute(db)
.await
.is_ok()
}
async fn last(db: &SqlitePool) -> Vec<Log> {
sqlx::query_as!(