adding a remove from db function

This commit is contained in:
Chris Cochrun 2025-09-17 09:27:10 -05:00
parent de0722b430
commit e2406b5462
6 changed files with 245 additions and 29 deletions

View file

@ -168,6 +168,17 @@ impl Model<Image> {
}
}
pub async fn remove_from_db(
db: PoolConnection<Sqlite>,
id: i32,
) -> Result<()> {
query!("DELETE FROM images WHERE id = $1", id)
.execute(&mut db.detach())
.await
.into_diagnostic()
.map(|_| ())
}
pub async fn update_image_in_db(
image: Image,
db: PoolConnection<Sqlite>,