Skip to content

Commit

Permalink
fixed the bugs on post queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jameel914 committed Nov 13, 2023
1 parent 932f1bd commit 8c88d94
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions back-end/queries/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ const getSong = async (id) => {
const createSong = async (song) => {
try {
const newSong = await db.one(
"INSERT INTO songs (name, artist, album, time, is_favorite) VALUES ($1, $2, $3, $4, $5) RETURNING *",
[song.name, song.artist, song.album, song.time, song.is_favorite]
"INSERT INTO songs (name, artist, album, time, is_favorite, albums_id) VALUES ($1, $2, $3, $4, $5, $6) RETURNING *",
[
song.name,
song.artist,
song.album,
song.time,
song.is_favorite,
song.albums_id,
]
);
return newSong;
} catch (error) {
Expand All @@ -49,15 +56,7 @@ const updateSong = async (song) => {
try {
const updatedSong = await db.one(
"UPDATE songs SET name=$1, artist=$2, album=$3, time=$4, is_favorite=$5 WHERE id=$6 RETURNING *",
[
song.name,
song.artist,
song.album,
song.time,
song.is_favorite,
song.albums_id,
song.id,
]
[song.name, song.artist, song.album, song.time, song.is_favorite, song.id]
);
return updatedSong;
} catch (error) {
Expand Down

0 comments on commit 8c88d94

Please sign in to comment.