title: Not able to delete lowest score from array of documents in MongoDB
body: <p>This is how my collection looks:</p>
  
  <pre><code>db.students.find({_id:100}).pretty()
  {
      "_id" : 100,
      "name" : "Demarcus Audette",
      "scores" : [
          {
              "type" : "exam",
              "score" : 30.61740640636871
          },
          {
              "type" : "quiz",
              "score" : 14.23233821353732
          },
          {
              "type" : "homework",
              "score" : 31.41421298576332
          },
          {
              "type" : "homework",
              "score" : 30.09304792394713
          }
      ]
  }
  </code></pre>
  
  <p>I am executing the following 2 queries on Mongo shell:</p>
  
  <pre><code>x=db.students.aggregate( [{ "$unwind":"$scores" },{"$match":{"scores.type":"homework"}},{ "$group":{"_id":"$_id","minscore":{"$min":"$scores.score" }}} ] )
  </code></pre>
  
  <p>and the next one is:</p>
  
  <pre><code>for (var a in x["a"]) { db.students.update( { "_id":a["_id"] },{"$pull":{"scores":{"score":a["minscore"]}}} ) }
  </code></pre>
  
  <p>I am able to see the min score list, but when I execute the second query nothing seems to be deleted. I know there is a logical error. I tried to read on the posts here, but I couldn't get pas through it. I just wanted to know where was I going wrong.</p>