summaryrefslogtreecommitdiff
path: root/src/db/story.rs
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2024-11-07 18:35:27 +0100
committerWriterV2 <primary-v2@protonmail.com>2024-11-07 18:35:27 +0100
commit680867b4bb5e2708f02fc3f8c21c3563975c44c7 (patch)
tree0e90e583f1696d3c7c66484a5f8dbd919c75245d /src/db/story.rs
parent99fc959383d5b7b26d8e80f6257adf8b98989f41 (diff)
Feat: Add admin API route to delete story by product id
Diffstat (limited to 'src/db/story.rs')
-rw-r--r--src/db/story.rs13
1 files changed, 13 insertions, 0 deletions
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 {