From 51b5b5cd3b76eda147289eed51b1e4c3195fad95 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Thu, 21 Nov 2024 07:07:15 -0800 Subject: [PATCH] feat: db backed record removal --- queries/records/remove_record.sql | 2 ++ src/router/link.rs | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 queries/records/remove_record.sql diff --git a/queries/records/remove_record.sql b/queries/records/remove_record.sql new file mode 100644 index 0000000..979ff43 --- /dev/null +++ b/queries/records/remove_record.sql @@ -0,0 +1,2 @@ +DELETE FROM records +WHERE cache_name = ?; diff --git a/src/router/link.rs b/src/router/link.rs index bfa6511..3867e28 100644 --- a/src/router/link.rs +++ b/src/router/link.rs @@ -48,6 +48,15 @@ async fn link_delete( .await .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; + { + let mut conn = state.pool.acquire().await.unwrap(); + + sqlx::query_file!("queries/records/remove_record.sql", id) + .execute(&mut *conn) + .await + .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; + } + Ok(Html("".to_string())) }