From a81750279342bf2473e5a5df930c34f49551f020 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Thu, 21 Nov 2024 15:30:08 -0800 Subject: [PATCH] feat: delete no longer touches records --- src/router/link.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/router/link.rs b/src/router/link.rs index 70b5ef0..9c86f8a 100644 --- a/src/router/link.rs +++ b/src/router/link.rs @@ -46,21 +46,16 @@ async fn link( async fn link_delete( axum::extract::Path(id): axum::extract::Path, - State(mut state): State, + State(state): State, ) -> Result, (StatusCode, String)> { - state - .remove_record(&id) + 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()))?; - { - 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()))?; - } + drop(conn); Ok(Html("".to_string())) }