title: How to change datatype of nested field in Mongo document?
body: <p>My Mongo structure as below,</p>
  
  <pre><code>"topProcesses" : [
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "1",
              "memoryUtilizationPercent" : "0.1",
              "command" : "init",
              "user" : "root"
          },
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "2",
              "memoryUtilizationPercent" : "0.0",
              "command" : "kthreadd",
              "user" : "root"
          },
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "3",
              "memoryUtilizationPercent" : "0.0",
              "command" : "ksoftirqd/0",
              "user" : "root"
          },
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "5",
              "memoryUtilizationPercent" : "0.0",
              "command" : "kworker/0:+",
              "user" : "root"
          },
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "6",
              "memoryUtilizationPercent" : "0.0",
              "command" : "kworker/u3+",
              "user" : "root"
          },
          {
              "cpuUtilizationPercent" : "0.0",
              "processId" : "8",
              "memoryUtilizationPercent" : "0.0",
              "command" : "rcu_sched",
              "user" : "root"
          } 
      ]
  </code></pre>
  
  <p>Now in above documents <code>topProcesses.cpuUtilizationPercent</code> is in string and I wanted to change <code>topProcesses.cpuUtilizationPercent</code> data type to <code>Float</code>. For this I tried below but it did not work </p>
  
  <pre><code>db.collectionName.find({
     "topProcesses":{"$exists":true}}).forEach(function(data){
      for(var ii=0;ii&lt;data.topProcesses.length;ii++){
     db.collectionName.update({_id: data._id},{$set:{"topProcesses.$.cpuUtilizationPercent":parseFloat(data.topProcesses[ii].cpuUtilizationPercent)}},false,true);
    }
  })
  </code></pre>
  
  <p>Can any one help how to changed string to float in nested Mongo documents</p>