Search⌘ K
AI Features

Updating Resources by ID

Explore the process of updating resources by their unique ID in a NestJS REST API. Learn to implement the PATCH method for partial updates, distinguish it from PUT, and handle update logic in controllers and services.

Now that we know how to find books by their unique identifier, imagine the scenario where one of our books needs an update. Perhaps the author released a new edition, or there’s a change in its publication details. In this section, we’ll explore the process of updating the information for a specific book using its unique identifier.

The PUT or PATCH method

To make an update operation for a resource, such as a book, we often face a decision between two HTTP verbs: PUT or PATCH. Let’s provide a brief explanation of these verbs in the context of our use case:

  • The PUT method replaces a ...