From 001be869484e3e6dcc25a80b0436c7dba85c79da Mon Sep 17 00:00:00 2001 From: itsscb Date: Mon, 26 May 2025 21:54:59 +0200 Subject: [PATCH] feat: add removal of scripts --- src/db.rs | 13 +++++++++++++ src/router.rs | 5 +++-- src/router/routes/scripts.rs | 27 +++++++++++++++++++++------ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/db.rs b/src/db.rs index 194f2bb..671bb95 100644 --- a/src/db.rs +++ b/src/db.rs @@ -106,6 +106,19 @@ pub async fn get_script>(pool: &SqlitePool, id: T) -> Result<(Uuid )) } +#[allow(dead_code)] +pub async fn delete_script>(pool: &SqlitePool, id: T) -> Result<(), String> { + if let Err(e) = sqlx::query("DELETE FROM scripts WHERE id = ?") + .bind(id.as_ref()) + .execute(pool) + .await + { + Err(e.to_string()) + } else { + Ok(()) + } +} + // TODO: Return Vec