title: Mongo $pullAll on array of objects
body: <p>Currently I have a data structure like this in mongo: </p>
  
  <pre><code>{
      "_id": "field00048",
      "colorValues": [
          {
              "stateField": "Open1",
              "color": "purple"
          },
          {
              "stateField": "Open2",
              "color": "blue"
          }
      ]
  }
  </code></pre>
  
  <p>I am using the mongo shell to create a query using $pullAll to delete both of the objects in the colorValues array by matching on the stateField field. I have tried these queries but none of them actually delete the records they match on. </p>
  
  <pre><code>db.admin.fields.update({_id: "field00048"}, {$pullAll: {stateField: ["Open1", "Open2"]}});
  </code></pre>
  
  <p>and </p>
  
  <pre><code>db.admin.fields.update({_id: "field00048"}, {$pullAll: {colorValues: ["Open1", "Open2"]}});
  </code></pre>
  
  <p>and </p>
  
  <pre><code>db.admin.fields.update({_id: "field00048"}, {$pullAll: {colorValues: [{stateField:"Open1"}, {stateField:"Open2"}]}});
  </code></pre>
  
  <p>and</p>
  
  <pre><code>db.admin.fields.update({_id: "field00048"}, {$pullAll: {colorValues.stateField: ["Open1", "Open2"]}});
  </code></pre>
  
  <p>and </p>
  
  <pre><code>db.admin.fields.update({_id: "field00048"}, {$pullAll: {colorValues: stateField:{["Open1", "Open2"]}}});
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Thanks!</p>