在node.js put方法中,我如何从多个处理程序中更新特定值?

发布于 2025-01-29 02:03:54 字数 228 浏览 4 评论 0原文

在此处输入图像描述

  1. 在这里我从处理程序中更新数量(-1)的值。
  2. 我想从另一个处理程序中添加数量。
  3. 现在,如何通过在相同API和相同值的New Handler中从输入字段中添加新数量?

enter image description here

  1. Here I update the value of quantity (-1) from a handler .
  2. I want to add quantity from another handler.
  3. now how can add new quantity from a input field by new handler which is in the same Api and same value?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫言歌 2025-02-05 02:03:54

首先,我不建议根据客户端为您提供实际数量(请参阅updatedProduct.quantity -1),因为您永远无法信任它。 设置数量

我会首先获取它,然后查看有一个具有该ID的产品,并从那里获取数量,甚至使用$ inc ocer https://www.mongodb.com/docs/manual/manual/reference/reference/operator/operator/update/ininc/ininc/

不了解第2和3号问题。您能进一步解释吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文