我需要更新数组中的数组
{
_id:1,data:[{
dataId:1,nestedData :[{
nestedDataid:12,price:150
},{
nestedDataid:122,price:10
}]
},{
dataId:2,nestedData :[{
nestedDataid:42,price:10
},{
nestedDataid:42,price:10
}]
}]
}
我需要更新嵌套数组dataId =1
和嵌套nestedDataid=12
中的价格。我曾尝试过mongo $
{
"data.dataId": 1,"data.nestedData.nestedDataid": 12
},{
step: 3,$set: { "data.0.nestedData.$.price": 200 }
}
请让我知道如果我做错了任何事情,我们将不胜感激