diff --git a/lib/db/managing.ts b/lib/db/managing.ts index 2336fd1..f3c69b1 100644 --- a/lib/db/managing.ts +++ b/lib/db/managing.ts @@ -146,6 +146,20 @@ export async function attachSongToSongbook(songId: number, songbookId: number, n } } +export async function removeSongfromSongbook(songId: number, songbookId: number) { + try { + const info = db.prepare(` + DELETE FROM songbook_songs + WHERE songbook_id = ? AND song_id = ? + `).run(songbookId, songId); + + return { success: info.changes > 0 }; + } catch (error) { + console.error("Error in removeSongfromSongbook:", error); + return { success: false }; + } +} + export async function getSongbooks() { try { const songbooks = db.prepare('SELECT id, name, language FROM songbooks ORDER BY name ASC').all();