From 680867b4bb5e2708f02fc3f8c21c3563975c44c7 Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Thu, 7 Nov 2024 18:35:27 +0100 Subject: Feat: Add admin API route to delete story by product id --- src/db/story.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/db/story.rs') diff --git a/src/db/story.rs b/src/db/story.rs index 137c964..9e5fdb9 100644 --- a/src/db/story.rs +++ b/src/db/story.rs @@ -99,6 +99,19 @@ impl ProductDatabaseHandler for Story { Ok(story) } + + async fn delete(pool: &SqlitePool, pid: i64) -> Result<(), AppError> + where + Self: Sized, + { + let mut tx = pool.begin().await?; + sqlx::query!("DELETE FROM story WHERE pid = $1", pid) + .execute(&mut *tx) + .await?; + Product::delete(&mut tx, pid).await?; + tx.commit().await?; + Ok(()) + } } impl PageBuilder for Story { -- cgit v1.2.3