MongoDB 不带过滤器的 UpdateMany 子数组
MongoDB UpdateMany Child Array without filter
简单架构:
[
{
"key": 1,
"Array": [
{
"Prop1": 1,
"Prop2": 2
},
{
"Prop1": 2,
"Prop2": 3
},
]
},
]
我想更新所有子数组,但是 mongo 说 'The positional operator did not find the match needed from the query.'
db.collection.update({},
{
"$set": {
"Array.$.Prop1": ""
}
},
{
"multi": true,
"upsert": false
})
也许是这样的:
db.collection.update({},
{
"$set": {
"Array.$[].Prop1": ""
}
},
{
"multi": true,
"upsert": false
})
简单架构:
[
{
"key": 1,
"Array": [
{
"Prop1": 1,
"Prop2": 2
},
{
"Prop1": 2,
"Prop2": 3
},
]
},
]
我想更新所有子数组,但是 mongo 说 'The positional operator did not find the match needed from the query.'
db.collection.update({},
{
"$set": {
"Array.$.Prop1": ""
}
},
{
"multi": true,
"upsert": false
})
也许是这样的:
db.collection.update({},
{
"$set": {
"Array.$[].Prop1": ""
}
},
{
"multi": true,
"upsert": false
})