From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Controller fundamentals (@Patch handler) - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Controller fundamentals (@Patch handler)
Now, let's see how the patch request is carried out. So inside the controller file, I'll give patch handler and the method partial update. Let's define the functionality in the service file. Below the update method, I'll create a method partial update. And in the argument, I'll give id of type string, and we'll create a product data object with title, description, and price as properties. We are following the same logic like we did for the put request. And then in the method, we destructure the product object and the index value from the find product method with ID as parameter. Then we create a new object, updated product, and we merge the existing product object with the product data passed in the parameter. So any properties existing in the product data will override the corresponding properties in the product object, effectively updating the product with the new data. Then we assign the updated product object to the product array by giving this dot product index is equal to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Understanding controllers5m 10s
-
(Locked)
Controller fundamentals (@Get handler)4m 21s
-
(Locked)
Controller fundamentals (Headers)3m 35s
-
(Locked)
Controller fundamentals (@Post handler)8m 57s
-
(Locked)
Controller fundamentals (@Post handler), part 2 with modules6m 56s
-
(Locked)
Controller fundamentals (fetching params)6m 44s
-
(Locked)
Controller fundamentals (@Put handler)10m 18s
-
(Locked)
Controller fundamentals (@Patch handler)4m 8s
-
(Locked)
Controller fundamentals (@Delete handler)3m 24s
-
(Locked)
Request object4m 42s
-
(Locked)
Response object2m 6s
-
(Locked)
Fetching queries3m 24s
-
(Locked)
@HttpCode vs. @Res decorator3m 22s
-
(Locked)
HTTP response status2m 53s
-
(Locked)
-
-
-
-
-
-
-
-
-
-