title: MongoDB - Updating datatype in nested array for String to Number not working
body: <p>I tried to update the MongoDB nested arrays data types, It's updated <code>NaN</code> value. Could you please help me out, anyone. Thanks</p>
  
  <h2>MongoDB data:</h2>
  
  <p>This is my MongoDB data <code>productqtydetails</code> collection.</p>
  
  <pre><code>[{
      "_id" : ObjectId("5d31567ea23d120f087a9ab1"),
      "productId" : ObjectId("5d31567ea23d120f087a9aaf"),
      "sizes" : [ 
          {
              "name" : "4",
              "qty" : 3.0,
              "price" : "1500.0"
          }, 
          {
              "name" : "5",
              "qty" : 6.0,
              "price" : "1600.0"
          }, 
          {
              "name" : "6",
              "qty" : 7.0,
              "price" : "1700.0"
          }
      ]
  }
  ....
  ]
  </code></pre>
  
  <h2>Mongo Shell Script:</h2>
  
  <pre><code>db.productqtydetails.update({
      _id : ObjectId("5d31567ea23d120f087a9ab1")
      },
  {
      $set: {"sizes.$[].price": parseFloat("$sizes.$[].price") //Here I used parseInt(), NumberInt also
  }
  });
  </code></pre>
  
  <h2>Updated MongoDB data:</h2>
  
  <p>after ran the script. i got the <code>price : NaN</code> it is updated.</p>
  
  <pre><code>[{
      "_id" : ObjectId("5d31567ea23d120f087a9ab1"),
      "productId" : ObjectId("5d31567ea23d120f087a9aaf"),
      "sizes" : [ 
          {
              "name" : "4",
              "qty" : 3.0,
              "price" : NaN
          }, 
          {
              "name" : "5",
              "qty" : 6.0,
              "price" : NaN
          }, 
          {
              "name" : "6",
              "qty" : 7.0,
              "price" : NaN //need to update "price" : 1700.0
          }
      ]
  }
  ...
  ]
  </code></pre>