环境:MEAN技术堆栈
如何为targetProperty: "value199"
的集合更新所有文档中的所有字段
和对象targetObjId: 1
。将其更新为的值并不重要。
MongoDB文档布局:
{
"_id": 1,
"collection1": [
{
"targetObjId": 1,
"objA": {
"prop1": "value1",
"targetProperty": "value199",
}
},
{
"targetObjId": 2,
"objA": {
"prop1": "value1",
"targetProperty": "value2",
}
}
]
},
{
"_id" 2,
"collection1": [
{
"targetObjId": 1,
"objA": {
"prop1": "value1",
"targetProperty": "value199",
}
},
]
},
...
另一个例子: