adding a remove_from_db command to model<Song>
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2025-09-16 09:35:53 -05:00
parent 645411b59c
commit de0722b430
2 changed files with 54 additions and 18 deletions

View file

@ -1,15 +1,15 @@
use std::{collections::HashMap, option::Option, path::PathBuf};
use crisp::types::{Keyword, Symbol, Value};
use miette::{IntoDiagnostic, Result, miette};
use miette::{miette, IntoDiagnostic, Result};
use serde::{Deserialize, Serialize};
use sqlx::{
FromRow, Row, Sqlite, SqliteConnection, SqlitePool,
pool::PoolConnection, query, sqlite::SqliteRow,
pool::PoolConnection, query, sqlite::SqliteRow, Acquire, FromRow,
Row, Sqlite, SqliteConnection, SqlitePool,
};
use tracing::error;
use crate::{Slide, SlideBuilder, core::slide};
use crate::{core::slide, Slide, SlideBuilder};
use super::{
content::Content,
@ -407,6 +407,19 @@ impl Model<Song> {
}
}
}
pub async fn remove_from_db(
&mut self,
db: &mut SqlitePool,
id: i32,
) -> Result<()> {
let db = db.acquire().await.expect("probs");
query!("delete from songs where id = $1", id)
.execute(&mut db.detach())
.await
.into_diagnostic()
.map(|_| ())
}
}
pub async fn update_song_in_db(