I am having a JSON array object something like [{_id:64,minitem:30},{},{}...]
inside a variable result.. This is the result of an aggregation operation which is a projection of minimum score. I need to iterate over this result and delete the minvales from DB.
I am unable to loop over the result object .. I tried
for(i=0; i<result.length; i++){
db.students.update({
'_id': result['_id']
}, {
'$pull': { 'scores': { 'score': result[i]['minitem'] } }
})
}
This doesnt seem to have an effect. DB is unaltered. I am trying this from mongo
shell.