feat: add removeSongFromSongbook to db managing.ts

This commit is contained in:
robin committed 2026-07-28 16:27:25 +02:00
1 parent 297b4a9664
commit 57ea3907b6
1 file changed
+14
+14
View File
@@ -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() { export async function getSongbooks() {
try { try {
const songbooks = db.prepare('SELECT id, name, language FROM songbooks ORDER BY name ASC').all(); const songbooks = db.prepare('SELECT id, name, language FROM songbooks ORDER BY name ASC').all();