Here is the schema of my collection "profile"
{
_id : ObjectId("123"),
name : "Tommy",
defaultrates :
[
{_id : ObjectId("111"), rate : 35.0, raisedOn : "5/2/2009"},
{_id : ObjectId("222"), rate : 55.0, raisedOn : "5/3/2010"},
{_id : ObjectId("333"), rate : 65.0, raisedOn : "5/5/2010"}
]
}
I want to remove the first index of default rates ({_id : 111, rate : 35.0, raisedOn : "5/2/2009"}).
The result should be:
{
_id : ObjectId("123"),
name : "Tommy",
defaultrates :
[
{_id : ObjectId("222"), rate : 55.0, raisedOn : "5/3/2010"},
{_id : ObjectId("333"), rate : 65.0, raisedOn : "5/5/2010"}
]
}
I did this in the console:
db.profile.update({'_id: ObjectId("123")},{ $pull: { 'defaultrates':{'_id': "111"}}},{ multi: false })
But sadly, it didn't gave me the desired output.
Please help. What's the proper way of doing this?