title: Mongo 3.2: Update All Array Elements That Match Condition
body: <p>I want a query to update <code>pmd</code> and <code>ed</code> for all <code>DEF</code> array if <code>isActive</code> is <code>true</code>, the positional operator is available from Mongo 3.6 onwards. </p>
  
  <p>Can someone suggest something equivalent to positional operator in Mongo 3.2:</p>
  
  <p>Document:</p>
  
  <pre><code>{
      "_id" : {
          "_id" : "123456789",
          "globalId" : "00012345001"
      },
      "regionalAttributes" : {
          "CAD" : {
              "priceS" : "XYZ",
              "mdClusters" : {
                  "DEF" : [ 
                      {
                          "cId" : "129",
                          "cName" : "815",
                          "pmd" : ISODate("2018-01-04T00:00:00.000Z"),
                          "ed" : ISODate("2018-04-15T00:00:00.000Z"),
                          "isActive" : false
                      }, 
                      {
                          "cId" : "193",
                          "cName" : "811",
                          "pmd" : ISODate("2019-06-29T00:00:00.000Z"),
                          "ed" : ISODate("2019-05-30T00:00:00.000Z"),
                          "isActive" : true
                      }, 
                      {
                          "cId" : "194",
                          "cName" : "812",
                          "pmd" : ISODate("2018-01-04T00:00:00.000Z"),
                          "ed" : ISODate("2018-04-15T00:00:00.000Z"),
                          "isActive" : true
                      }
                  ]
              }
          }
      }
  }
  </code></pre>
  
  <p>I tried elemMatch but it is updating only first matched array</p>
  
  <pre><code> db.getCollection('items').updateMany(
  
      { "_id._id" : "123456789",{ "regionalAttributes.CAD.mdClusters.DEF": { "$elemMatch": {"isActive": true }} }},
      {"$set" : { "regionalAttributes.CAD.mdClusters.DEF.$.pmd" : ISODate("2019-05-29T00:00:00.000Z") , 
      "regionalAttributes.CAD.mdClusters.DEF.$.ed" : ISODate("2019-06-26T00:00:00.000Z")}});
  </code></pre>