title: How to iterate through result object after querying in mongo DB shell
body: <p>I am having a JSON array object something like <code>[{_id:64,minitem:30},{},{}...]</code> 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 </p>
  
  <pre><code>for(i=0; i&lt;result.length; i++){ 
    db.students.update({ 
          '_id': result['_id']
        }, { 
           '$pull': { 'scores': { 'score': result[i]['minitem'] } } 
        }) 
    }
  </code></pre>
  
  <p>This doesnt seem to have an effect. DB is unaltered. I am trying this from <code>mongo</code> shell.</p>