title: Express JS PUT not saving but it's updating
body: <p>I've an express JS application in which I'm trying to PUT(update an existing user's name). My schema is nested array and looks like this :</p>
  
  <p><a href="https://i.stack.imgur.com/WDIse.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WDIse.png" alt="enter image description here"></a></p>
  
  <p>My code to update this user using PUT looks like this :</p>
  
  <pre><code>router.route('/sensors_update/:_id/')
      .put(function (req, res) {
          console.log("inside update put")
          User.findById(req.params._id, function(err, user) {
              if (err)
                  res.send(err);
              console.log(user);
              user.name = req.body.name;
              console.log("User val is" + user);
              user.save();
          });
      });
  </code></pre>
  
  <p>I'm able to clearly see the <strong>user's name</strong> is updating using the JS console. But I've issues when it comes to saving this user object. I guess this should be because I've a nested schema. Is my assumption right? Any suggestions regarding how to save an user object with nested arrays.</p>
  
  <p>Here is the console message:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>inside update put
  { _id: 'Manasa',
    name: 'Manasa Sub',
    __v: 0,
    sensors: 
     [ { sensor_name: 'ras',
         _id: 57da0a4bf3884d1fb2234c74,
         measurements: [Object] } ] }
  User val is{ _id: 'Manasa',
    name: 'Manas Sub',
    __v: 0,
    sensors: 
     [ { sensor_name: 'ras',
         _id: 57da0a4bf3884d1fb2234c74,
         measurements: [Object] } ] }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I was wondering why the nested array is accessed when I'm just trying to update&amp;save the name of user.</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>_http_outgoing.js:335
      throw new Error('Can\'t set headers after they are sent.');
            ^
  Error: Can't set headers after they are sent.</p>
  
  <p>How can I solve this ?</p>
  
  <p>Response :</p>
  
  <pre><code>    {
       "message": "Cast to date failed for value \"7:00\" at path \"time\"",
       "name": "CastError",
        "type": "date",
         "value": "7:00",
        "path": "time"
        }
  </code></pre>