I have a document in the following format,
{
"entities":[
{
"info":{
"configId":[
"1234",
"3213"
]
}
},
{
"info":{
"configId":[
"73683",
"38297",
"1234"
]
}
},
{
"info":{
"configId":["32683" ]
}
}
]
}
How can I remove "1234" from all the configId arrays in one update command?
I was trying the following, but it only updates the first one.
db.asset.update({
"entities.info.configId": "1234"
},
{
$pull:{
"entities.$.info.configId":{
$in:[ "1234" ]
}
}
});
Thanks.
Edit:
This query is finally working for me:
db.asset.update({
"entities.info.configId": "1234"
},
{
$pull:{
"entities.$[].info.configId":{
$in:[ "1234" ]
}
}
});