I have a collection like this
{
"_id" : ObjectId("5446757568567546456"),
"name" : "Duck-trailer",
"data" : [
{
"date" : "1-1-2015",
"oldPrice" : 10,
"price" : 15
},
{
"date" : "2-1-2015",
"oldPrice" : 10
"price" : 12
}
]
}
So I try to select by id and date , then update the price by selecting the date which is nested within the data object.
My query did not work, got error of MongoError: cannot use the part..
myModel.update({_id: id, 'data.$.date':'2-1-2015'}, {'$set': {'data.$.price': 100}},
function(err,result) {
})