node.js - 如何更新数组中的特定对象?
问题描述
我在 MongoDB 中有一个如下所示的数据
{
_id: aasdfeasfeasdf,
todo: [
{_todoIde: 333, _with: []},
{_todoIde: 111, _with: []},
]
}
我要$addToSet
重视_todoIde: 333
的_with
喜欢{_todoIde: 333, _with: [aaaa]},
。我该怎么做?
.updateOne(
{_id},
{ $addToSet: {}}
)
我找到了该文档,但我无法指定_todoIde: 333
仅更新该文档。
解决方案
推荐阅读
- c++ - CMake 编译时不包含链接库的路径
- python - 创建从 pyspark 到 HDFS 的 JSON 批量输出
- angular7 - 如何根据 Mat-Dynamic-Table Angular 中的 json 响应更改 mat-cell 颜色?
- linux - #!/bin/csh Cshell 检查查找结果 if else
- javascript - 我只想 console.log() 我的数据存在于我的 MongoDB 数据库中
- python - Python Pandas 数据框创建一个新列,其中包含另一列的减法
- python - Python中计算平均列的问题
- r - R:ggplot 上的自定义方程。带有第三个变量的 stat_function
- merge - 合并一个对象中的两个列表,包括长度检查
- http - 通过 curl 发出肥皂请求不起作用并且服务器返回“来自服务器的空回复”