'In Node.js PUT method how i can update a specific value from multiple handler?
- Here I update the value of quantity (-1) from a handler .
- I want to add quantity from another handler.
- now how can add new quantity from a input field by new handler which is in the same Api and same value?
Solution 1:[1]
First of all, I don't recommend depending on the client to give you the actual quantity (See updatedProduct.quantity - 1) cause you can never trust it. I would fetch it first and see there is a product with that id and get the quantity from there, or even set the quantity using the $inc operator
https://www.mongodb.com/docs/manual/reference/operator/update/inc/
I didn't understand questions number 2 and 3. Can you explain further?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ron Hillel |
