【发布时间】:2022-08-02 17:09:07
【问题描述】:
我将 MongoDB 模型定义为: enter image description here
每个 rToken 都是独一无二的。我想从用户在请求正文中指定的 rToken 数组中删除一个元素,因此,我在下面创建了一个路由: enter image description here
但它没有删除元素,我仍然获得 204 状态。请帮忙。
-
请不要以图像的形式提供源代码,而应以文本的形式提供。
我将 MongoDB 模型定义为: enter image description here
每个 rToken 都是独一无二的。我想从用户在请求正文中指定的 rToken 数组中删除一个元素,因此,我在下面创建了一个路由: enter image description here
但它没有删除元素,我仍然获得 204 状态。请帮忙。
如果 rToken 是一个数组,您可以删除这样的元素,假设您删除了密码密钥:
const { password, ...rTokenWithoutPassword } = rToken;
然后使用 rTokenWithoutPassword 做任何事情。
如果要删除多个密钥、盐和密码,例如:
const { password, salt, ...rTokenWithoutPassword } = rToken;
【讨论】: