Getting error "pipeline element 3 is not an object error", while trying to find & update using aggregate
<p>I am using <code>node js mongodb driver</code> &amp; trying to update an <code>object array</code> inside an object array in a document. </p>

<p>The <strong>schema</strong> of the document collection is this : </p>

<p><a href="https://i.stack.imgur.com/g0cLY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g0cLY.png" alt="enter image description here"></a></p>

<p><strong>What I Want :</strong> </p>

<p>For collection with <code>order no = 1 &amp; items.qty=2 &amp; tax rate = 25</code>,  update the <code>tax to "cst" &amp; taxratetype to "flat"</code>.</p>

<p><strong>What I Tried :</strong> </p>

<pre><code>db.OrderInfo.aggregate(
    {$match:{"orderno":"1"}},
    {$unwind:'$items'},
    { $match: { 'items.qty' : 2} 
 },function(err,result1){
    if(err){
    throw(err);
   }else{
   indexes = result1[0].items.taxes.map(function(obj, index) {
      if(obj.taxrate == 25) {
      return index;
   }
   }).filter(isFinite);

var updateData = {};
updateData["items.$.taxes."+indexes[0]+".tax"]="cst";
updateData["items.$.taxes."+indexes[0]+".taxratetype"]="flat";


db.OrderInfo.update({ "orderno":"1",'items.qty': 2,'items.taxes.taxrate': 25 },{$set: updateData },function(err,result2){
console.log(result2);
});

}
});
</code></pre>

<hr>

<p>Currently I am using <strong>db.eval</strong> to run this script from node but later will change it once I accomplish the same.</p>

<p><strong>Getting this Error :</strong></p>

<blockquote>
  <p>{"name":"MongoError","message":"Error: command failed: {\n\t\"ok\" :
  0,\n\t\"errmsg\" : \"pipeline element 3 is not an
  object\",\n\t\"code\" : 15942\n} : aggregate failed
  :\n_getErrorWithCode@src/mongo/shell/utils.js:25:13\ndoassert@src/mongo/shell/assert.js:13:14\nassert.commandWorked@src/mongo/shell/assert.js:267:5\nDBCollection.prototype.aggregate@src/mongo/shell/collection.js:1312:5\n_funcs1@:1:31\n","ok":0,"errmsg":"Error:
  command failed: {\n\t\"ok\" : 0,\n\t\"errmsg\" : \"pipeline element 3
  is not an object\",\n\t\"code\" : 15942\n} : aggregate failed
  :\n_getErrorWithCode@src/mongo/shell/utils.js:25:13\ndoassert@src/mongo/shell/assert.js:13:14\nassert.commandWorked@src/mongo/shell/assert.js:267:5\nDBCollection.prototype.aggregate@src/mongo/shell/collection.js:1312:5\n_funcs1@:1:31\n","code":139}</p>
</blockquote>

<p>I know from this issue <a href="https://jira.mongodb.org/browse/SERVER-831" rel="nofollow noreferrer">https://jira.mongodb.org/browse/SERVER-831</a>
that I cannot use a direct update command &amp; hence trying this workaround.
Any other approach for such updates is also fine with me.</p>

<p><strong>EDIT :</strong>
As per answer given by @titi23, I had tried using [] also inside function. 
It did not gave me any error but, my values also did not get updated.</p>