title: update nested array element value in node js mongoDB
body: <p>Hi i am new in nodejs i need to update a value in nested array using  _id of document my database document is look like this..</p>
  
  <pre><code>"complaints" : [ 
      {
          "complaint" : "head light is not working",
          "complaintid" : ObjectId("57205219a56d2b8c0f9274a4"),
          "_id" : ObjectId("57454c9249218eb40c1c0d1f"),
          "labour" : 350,
          "partCost" : 0,
          "part" : [ 
              {
                  "id" : ObjectId("56f12eaab915bd9800272ed7"),
                  "estimate" : 450,
                  "partname" : "clutch",
                  "_id" : ObjectId("57454cef49218eb40c1c0d25"),
                  "quantity" : 0,
                  "qrcodes" : []
              }, 
              {
                  "id" : ObjectId("56f12eaab915bd9800272ed7"),
                  "estimate" : 450,
                  "partname" : "rear tyre",
                  "_id" : ObjectId("57454cef49218eb40c1c0d24"),
                  "quantity" : 0,
                  "qrcodes" : []
              }
          ],
          "acceptance" : true,
          "inspection" : false,
          "color" : "#8929A9",
          "status" : "APPROVED",
          "estimate" : 1200,
          "solution" : "HEAD LIGHT CHANGE",
          "problems" : "HEAD LIGHT IS NOT WORKING"
      }, 
  </code></pre>
  
  <p>i need to update quantity value of part array exist inside the part array  using _id of part array</p>
  
  <p>i am trying this but its not working what should i do for update this value...</p>
  
  <pre><code>var partdata = req.payload.parts;
                  for(var k = 0; k&lt; partdata.length ; k++ ){
                      CPS.update({
                          'complaints.part._id' : partdata[k].partid
                      }, {
                          "$inc" : {                              
                              'complaints.part.$.quantity' : partdata[k].quantity                             
                          }
                      }).exec
                      (function(err,temp) {
                          if(err){
                              res(err).code(500);
                          }else{
                              console.log(temp);
                          }
                      });
                  }
  </code></pre>