I am trying to update nested field of a ducument, but don't why it is not getting succeeded. Please help.
My document structure is like :
{
"_id": {
"$oid": "594d173df36d285a33da90cf"
},
"available": 1,
"brand": [
{
"_id": {
"$oid": "59db10918bbe2316281d58d1"
},
"name": "test",
"createdby": "***************",
"createdon": "Mon Oct 09 2017 11:30:42 GMT+0530 (India Standard Time)",
"feedbacks": [
{
"_id": {
"$oid": "5a1039c25443604328ecf398"
},
"feedback": "hello",
"date": "Sat Nov 18 2017 19:16:36 GMT+0530 (India Standard Time)",
"reportedby": []
},
{
"_id": {
"$oid": "5a1039c25498504328ecf398"
},
"feedback": "hello",
"date": "Sat Nov 18 2017 19:16:36 GMT+0530 (India Standard Time)",
"reportedby": []
}
]
}
]
}
And my query is like :
db.products.update({
'_id': mongojs.ObjectId(594d173df36d285a33da90cf),
'brand._id': mongojs.ObjectId(59db10918bbe2316281d58d1),
'brand.feedbacks._id': mongojs.ObjectId(5a1039c25498504328ecf398),
}, {
$addToSet: { 'brand.feedbacks.reportedby': skillSet.userId }
},
function(err, products) {
})
The error is like : { n: 0, nModified: 0, opTime: { ts: Timestamp { bsontype: 'Timestamp', low: 1, high_: 1512829477 }, t: 5 }, electionId: 7fffffff0000000000000005, ok: 1 }