title: bulkWrite - TypeError: Cannot create property '$set' on number '0' at applyTimestampsToUpdate - mongoose or mongodb
body: <p>I tried have <strong>bulkWrite</strong> query for update multiple and different documents in a single time, customer order multiple products at the time updating the product quantity details. I found <a href="https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/index.html#updateone-and-updatemany" rel="nofollow noreferrer">bulkWrite updateOne</a> query. this bulk array updates at a single time.</p>
  
  <h2>Code :</h2>
  
  <p>while upding the <strong>key value</strong> <code>update: { $set: { 'colorName' : null} }</code> working fine. but using nested array key value <code>update: { $set: { 'sizes.$.qty' : data.qty} }</code> not working. </p>
  
  <pre><code>poductModel.bulkWrite(arrayValue.map((data) =&gt; ({
              updateOne: {
            filter: { _id: data.productQtyDetailsId, 'sizes.name' : data.sizeName },
  
            update: { $set: { 'sizes.$.qty' : data.qty} } 
        //working fine
        //update: { $set: { 'colorName' : null} } 
  
          }
        }))).then(err,result =&gt; {
  
        })
  </code></pre>
  
  <h2>JSON data:</h2>
  
  <pre><code>    [
    {
      "qty": 8,
      "productId": "5d31567ea23d120f087a9aaf",
      "productQtyDetailsId": "5d316373b356873504e78be7",
      "sizeName": "4",
      "colorName": "green",
    },
    {
      "qty": 5,
      "productId": "5d31567ea23d120f087a9aaf",
      "productQtyDetailsId": "5d31567ea23d120f087a9ab1",
      "sizeName": "4",
      "colorName": "blue",
    }
  ]
  </code></pre>
  
  <h2>Mongo DB data :</h2>
  
  <pre><code>[
  {
      "_id" : ObjectId("5d316373b356873504e78be7"),
      "colorName" : "green",
      "productId" : ObjectId("5d31567ea23d120f087a9aaf"),
      "sizes" : [ 
          {
              "name" : "4",
              "qty" : 5.0,
              "price" : 1500.0
          }, 
          {
              "name" : "5",
              "qty" : 6.0,
              "price" : 1600.0
          }, 
          {
              "name" : "6",
              "qty" : 7.0,
              "price" : 1700.0
          }
      ]
  }
  
  {
      "_id" : ObjectId("5d31567ea23d120f087a9ab1"),
      "colorName" : "blue",
      "productId" : ObjectId("5d31567ea23d120f087a9aaf"),
      "sizes" : [ 
          {
              "name" : "4",
              "qty" : 5.0,
              "price" : 1500.0
          }, 
          {
              "name" : "5",
              "qty" : 6.0,
              "price" : 1600.0
          }, 
          {
              "name" : "6",
              "qty" : 7.0,
              "price" : 1700.0
          }
      ]
  },
  ...
  ]
  </code></pre>