Skip to content

Commit

Permalink
set default value null for insert video
Browse files Browse the repository at this point in the history
  • Loading branch information
RbAvci committed May 26, 2024
1 parent 961f4cd commit f68931d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ router.post("/videos", async (req, res) => {
try {
const result = await db.query(
"INSERT INTO videos (title, src, rating) VALUES ($1, $2, $3) RETURNING id",
[title, src, rating ?? 0]
[title, src, rating ?? null]
);

const newVideoId = result.rows[0].id;
Expand All @@ -53,7 +53,6 @@ router.delete("/videos/:id", async (req, res) => {
await db.query("DELETE FROM videos WHERE id = $1", [videoId]);
return res.status(204).end();
} catch (error) {
console.error(error);
res
.status(500)
.json({ message: "An error occurred while deleting the video" });
Expand Down

0 comments on commit f68931d

Please sign in to comment.