title: MongooseJS: `TypeError: Object #<Object> has no method 'save'`: Cannot save part of a document?
body: <p>I was looking on stack overflow on how to retrieve an array element and I found so by looking at this link here:</p>
  
  <p>Retrieve only the queried element in an object array in MongoDB collection</p>
  
  <p>Below is the query I created from following this question:</p>
  
  <pre><code>exports.confirmFriend = function(req, res){
    if(req.body._id) {delete req.body._id}
      User.findOne({'username': req.params.username}, {'friends': {$elemMatch: {'username': req.body.username}}}, function (err, user){
        if(err) { return handleError(res, err); }
        if(!user) { return res.send(404); }
        //This is because $elemMatch returns only the first element so only 1 element will be populated
        user.friends[0] = req.body;
        user.save();
        //Here I want to UPDATE or SAVE the document that I queried for now
      });
  </code></pre>
  
  <p>Now that I have queried for my user.friends element and I have assigned req.body to it properly with the correct contents, I was wondering, is there a way to update or save the document I have performed this assignment/query on? when I call <code>user.save()</code> at the end of the assignment, I get an error saying: <code>TypeError: Object #&lt;Object&gt; has no method 'save'</code>. Any ideas on how to fix this? Thanks!</p>