[英]In Node.js PUT method how i can update a specific value from multiple handler?
enter image description here在此处输入图像描述
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.首先,我不建议依赖客户给你实际数量(见updatedProduct.quantity - 1
)因为你永远不能相信它。 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
我会先获取它并查看具有该 id 的产品并从那里获取数量,甚至使用$inc operator
设置数量
https://www.mongodb.com/docs/manual/reference/operator/update/inc/ https://www.mongodb.com/docs/manual/reference/operator/update/inc/
I didn't understand questions number 2 and 3. Can you explain further?我不明白第 2 和第 3 个问题。你能进一步解释一下吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.