AI comments cleanup

This commit is contained in:
rudi committed 2026-07-31 10:46:35 +02:00
1 parent df8a768e3e
commit d0890347dc
1 file changed
+3 -5
+3 -5
View File
@@ -17,7 +17,7 @@ export async function addSongToBook(songId: number, bookId: number, songNumber:
return { success: false, error: "Songnumber already taken in this songbook" }; return { success: false, error: "Songnumber already taken in this songbook" };
} }
const entry = await prisma.songBook.create({ // Verknüpfungs-Tabelle const entry = await prisma.songBook.create({
data: { data: {
songId, songId,
bookId, bookId,
@@ -49,13 +49,11 @@ export async function addSongToBook(songId: number, bookId: number, songNumber:
*/ */
export async function updateSongInBook(songId: number, bookId: number, data: {songNumber: number}) { export async function updateSongInBook(songId: number, bookId: number, data: {songNumber: number}) {
try { try {
// 1. Prüfen, ob die neue Nummer bereits vergeben ist
const isTaken = await isSongNumberTaken(bookId, data.songNumber); const isTaken = await isSongNumberTaken(bookId, data.songNumber);
if (isTaken) { if (isTaken) {
return { success: false, error: "New song number is already taken in this songbook" }; return { success: false, error: "New song number is already taken in this songbook" };
} }
// 2. Eintrag über den Composite Primary Key (songId_bookId) aktualisieren
const entry = await prisma.songBook.update({ const entry = await prisma.songBook.update({
where: { where: {
songId_bookId: { songId_bookId: {
@@ -75,12 +73,12 @@ export async function updateSongInBook(songId: number, bookId: number, data: {so
return { success: true, entry }; return { success: true, entry };
} catch (error: any) { } catch (error: any) {
// P2025 = Record to update not found (Verknüpfung existiert noch gar nicht) // P2025 = Record to update not found
if (error?.code === "P2025") { if (error?.code === "P2025") {
return { success: false, error: "Song is not assigned to this songbook" }; return { success: false, error: "Song is not assigned to this songbook" };
} }
// P2002 = Unique Constraint Violation (z.B. neue Nummer doch schon besetzt) // P2002 = Unique Constraint Violation
if (error?.code === "P2002") { if (error?.code === "P2002") {
return { success: false, error: "Song number already exists in this songbook" }; return { success: false, error: "Song number already exists in this songbook" };
} }