How do I update a value inside a object inside an array. I will provide the exact array number in a variable... Heres my code:
var num = 0;
var ObjectID=require('mongodb').ObjectID;
db.collection('polls').findAndModify({
query: {_id: ObjectID(_id param)},
update: { $inc: { total: 1, "Data.chart." + num.toString + ".value": 1} }
});
This is what I want to update
{total: 0, "Data": [
{ value: 0, label: 'Beatles', color: '#4169E1' },
{ value: 0, label: 'Sting', color: '#C0C0C0' },
{ value: 0, label: 'Police', color: '#FFA500' },
{ value: 0, label: 'Journey', color: '#FF4500' },
{ value: 0, label: 'Genesis', color: '#EE82EE' }
]
}