title: Meteor nested array update using $[<identifier>]
body: <p>I have following document (I cannot change structure of document)</p>
  
  <pre><code>{
    name: "Plastic",
    items: [
      {
         collection: "Toys",
         items: [{color: "red", etc.}, ...]
      },
      {
         collection: "Window":
         items: [{color: "blue", etc.} ...]
      }
    ]
  }
  </code></pre>
  
  <p>Now I want to add items into <strong>Toys.items</strong>. So, as far as I understand I should use <a href="https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/" rel="nofollow noreferrer">positioned filtered operator <code>$[&lt;idetifier&gt;]</code></a> for mongodb update function. However Meteor update function only accepts function as following</p>
  
  <pre><code>Mongo.Collection#update(selector, modifier, [options], [callback])
  </code></pre>
  
  <p>according to <a href="https://docs.meteor.com/api/collections.html#Mongo-Collection-update" rel="nofollow noreferrer">documenation</a>. So, I wonder how I can achieve similar result in meteor? In mongodb following should work:</p>
  
  <pre><code>db.collection.update(
     { name: "Plastic" },
     { $push: { "items.$[name].items": {color: "Red", etc} } },
     { arrayFilters: [ {"name.collection": "Toys"} ] }
  )
  </code></pre>
  
  <p>P.S: My mongo db 4.0.0 and Meteor 1.7.0.3</p>