clean duplicate speicifications
All checks were successful
CI/CD Pipeline / test (push) Successful in 18m54s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2025-05-11 20:52:13 +02:00
parent f86d2f6307
commit 396fc8e659
2 changed files with 45 additions and 70 deletions

View File

@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use std::ops::DerefMut;
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct Location {
@@ -37,6 +38,20 @@ impl Location {
.await
.ok()
}
pub async fn find_by_name_tx(db: &mut Transaction<'_, Sqlite>, name: String) -> Option<Self> {
sqlx::query_as!(
Self,
"
SELECT id, name
FROM location
WHERE name=?
",
name
)
.fetch_one(db.deref_mut())
.await
.ok()
}
pub async fn all(db: &SqlitePool) -> Vec<Self> {
sqlx::query_as!(Self, "SELECT id, name FROM location")