- 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?
Asked
Active
Viewed 175 times
-5

Md Imran Hossein
- 1
- 1
-
2Code for your question should be in plain text in your question, NEVER in images. This is for a whole bunch of reasons such as people writing answers can copy/paste code into answers instead of having to retype it all, text can be indexed for searching, text is easier to read on mobile, etc... Don't insert images of code here. Please use the "edit" button to fix your question now. – jfriend00 May 15 '22 at 20:10
1 Answers
0
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?

Ron Hillel
- 160
- 6