title: Mongoose-MongoDb : doc.pull inconsistent when multiple pull
body: <p>node v7.7.1
  mongodb: 2.2.33,
  mongoose: 4.13.7</p>
  
  <p>Hello all,</p>
  
  <p>i'm having this unexpected behaviour when trying to update a document with multiple pull request based on matching criterias. here is what i mean</p>
  
  <p>my document schma looks like this</p>
  
  <pre><code>{
      "_id": "5a1c0c37d1c8b6323860dfd0",
      "ID": "1511781786844",
      "main": {
          "_id": "5a3c37bfc065e86a5c593967",
          "plan": [
              {
                  "field1": 1,
                  "field2": 1,
                  "_id": "5a3c30dfa479bb4b5887e56e",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 2,
                  "_id": "5a3c30e1a479bb4b5887e5c",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 3,
                  "_id": "5a3c37bfc065e86a5c593968",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 4,
                  "_id": "5a3c37bfc065e86a5c593655",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 5,
                  "_id": "5a3c30dfa479bb4b5887e56f",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 6,
                  "_id": "5a3c30e1a479bb4b6887e545",
                  "child": []
              },
              {
                  "field1": 1,
                  "field2": 7,
                  "_id": "5a3c37bfc065e86a5c5939658",
                  "child": []
              },
              {
                  "field1": 2,
                  "field2": 2,
                  "_id": "5a3c37bfc065e86a5c593963",
                  "child": []
              },
          ]
      },
          ...
          ....
  }
  </code></pre>
  
  <p>and this is my code to update the document:</p>
  
  <pre><code>Schema.findOne({ID: data.ID})
        .then(function(doc) {
  
          var array = doc.main.plan;
  
      for (i = 0; i &lt; array.length; i++) {
          if ( array[i].field1=== 1 )) {
              var id = array[i]._id;
              console.log('pulling');
              doc.pull( { _id: id });
          }
      }
  
      doc.save().then(function(doc) {
          console.log('saving');
          // console.log(doc);
          if (doc &amp;&amp; doc.docID) {
              return { success: true };
          } else {
              return { success: false, error: 'unknownError'}
          }
      })
  }
  </code></pre>
  
  <p>now the issue is let's say  my array has 7 objects that matches the test (array[i].theField === parseInt(updFields.theField)), when i run this and check the logs i see that it will basically pull half of the objects and do a save.</p>
  
  <p>so i would get 
  pulling
  pulling
  pulling
  pulling
  save.</p>
  
  <p>and then i have to run the code for the remaining 3 objects in the array and get 
  pulling
  pulling
  saving</p>
  
  <p>so i have to run  it a third time to completely clear the array.</p>
  
  <p>need help get this working</p>
  
  <p>thank you</p>