Kizspy.me
Question 2 (2 points) - Update a Book by ID
Objective:
Create a REST API to update an existing book by its ID. The request may include updated
title, author, genres, published Year, or availableCopies.

Endpoint: PUT /api/books/:id
Processing Requirements:
。 Validate that the book with the given ID exists.
。 Validate that any provided author and genre IDs exist in their collections.
o Update the relevant fields.
o Return the updated book document.
• Request Example:
{
"title": "Refactoring (2nd Edition)",
"author": "66211aaa12bcab1234567788",
"genres":["66211aaa12bcab1234567711", "66211aaa12bcab1234567722"],
"publishedYear": 2019,
"availableCopies": 6
Zoom
+ 100%
Close