title: Update multiple nested elements conditionally mongodb
body: <p>I have a collection of documents that looks like this:</p>
  <pre><code>[
    {&quot;_id&quot;:ObjectId('602a7a9ac0bf9d23c67a41ba'),
      'brand':'horn',
      'products':[
        {'type':'red','ticks':0,'name':'model 1'},
        {'type':'green','ticks':0,'name':'model 2'},
        {'type':'red','ticks':0,'name':'model 3'},
      ]
    },
    {&quot;_id&quot;:ObjectId('602a7a9ac0bf9d23c67a1234'),
      'brand':'leg',
      'products':[
        {'type':'red','ticks':0,'name':'model 1'},
      ]
    },
  ]
  </code></pre>
  <p>I would like to update all documents with the <code>brand:horn</code> and increment all products with not the <code>type:red</code> by 1.<br />
  I am currently querying this way:</p>
  <pre><code>coll.updateMany({ &quot;brand&quot;: &quot;horn&quot;, &quot;products.type&quot;: { $ne: &quot;red&quot; } }, { $inc: { &quot;products.$.ticks&quot;: 1 } }, { 'multi': true })  
  </code></pre>
  <p>However this is not working. Any advice on how to perform this update properly?
  Thanks</p>