How to pull inner array having key address1
"_id": 2,
"info": {
"address1": {
"city": {
"0": "Indore"
},
"state": {
"0": "MP"
}
},
"address2": {
"city": {
"0": "Mhow"
},
"state": {
"0": "MP"
}
}
}
After removing data should be :
"_id": 2,
"info": {
"address1": {
"city": {
"0": "Indore"
},
"state": {
"0": "MP"
}
}
}
I used this db.info.update({"_id":2},{'$pull':{"info":{"address1":{'$exists':true}}}})
But It gives error Cannot apply $pull/$pullAll modifier to non-array
From the mongo console:
Does this accomplish what you need?