diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2024-11-07 18:35:27 +0100 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2024-11-07 18:35:27 +0100 |
| commit | 680867b4bb5e2708f02fc3f8c21c3563975c44c7 (patch) | |
| tree | 0e90e583f1696d3c7c66484a5f8dbd919c75245d /src/db/product.rs | |
| parent | 99fc959383d5b7b26d8e80f6257adf8b98989f41 (diff) | |
Feat: Add admin API route to delete story by product id
Diffstat (limited to 'src/db/product.rs')
| -rw-r--r-- | src/db/product.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/db/product.rs b/src/db/product.rs index 06217c0..c21734e 100644 --- a/src/db/product.rs +++ b/src/db/product.rs @@ -5,7 +5,6 @@ use sqlx::{QueryBuilder, Sqlite, SqlitePool, Transaction}; use crate::error::AppError; -use super::producttag::ProductTag; use super::tag::Tag; use super::ProductDatabaseHandler; @@ -50,6 +49,12 @@ impl Product { } Ok(product) } + + pub async fn delete(tx: &mut Transaction<'static, Sqlite>, pid: i64) -> Result<(), AppError> { + sqlx::query!("DELETE FROM producttag WHERE pid = $1", pid).execute(&mut **tx).await?; + sqlx::query!("DELETE FROM product WHERE id = $1", pid).execute(&mut **tx).await?; + Ok(()) + } } pub trait ProductMarker { |
