title: Nodejs Mongoose Cannot update values in DB
body: <p>I am pretty new to Nodejs and MongoDB. This might be a simple error, but I cannot seem to update values from DB. I searched far and wide but my syntax is seem to be right. Please help me.</p>
  
  <pre><code>var dataConstruct = {}
  dataConstruct[fieldName] = fieldValue;
  updateRecordModel.find(dataConstruct , function(err, field) {
    if(err) {
      logger.error("Error deleting records. Error -" + err)
      callback(err, "Error while searching for record.Please cheack the values posted")
    }
    else {
      logger.info("JSON"+JSON.stringify(field[0].Option1));
      field[0].Option1="Max";
      logger.info("JSON"+JSON.stringify(field[0].Option1));
      if(field){
         //code to update
    }
    else{
      callback(err, "No such data present")
    }
    }
  
  }).lean();
  </code></pre>
  
  <p>Find is returning data . I am using .lean() to get javascript object instead of document model object so that I can modify data. I cannot seem to modify the data returned without using .lean() as is the problem in this post <a href="https://stackoverflow.com/questions/14504385/why-cant-you-modify-the-data-returned-by-a-mongoose-query-ex-findbyid">Why can&#39;t you modify the data returned by a Mongoose Query (ex: findById)</a> </p>
  
  <p>I tried to find the data and update or resave it, I tried all the update syntax and methods(including find and then save doc again) mentioned in this post <a href="https://scotch.io/tutorials/using-mongoosejs-in-node-js-and-mongodb-applications" rel="nofollow noreferrer">https://scotch.io/tutorials/using-mongoosejs-in-node-js-and-mongodb-applications</a> but none seem to work,as I cannot modify the data returned </p>
  
  <p>This is the json returned from find 
                 {"_id":"564c29d96bf38ba3039f4844","Option1":"Gary","Option2":"Fred","__v":0}</p>
  
  <p>I need to know how to update this value</p>
  
  <p>This is the code I used for findoneand update</p>
  
  <pre><code>    updateRecordModel.findOneAndUpdate({"Option1": "Gary" }, { "Option1": "Max" }, function(err,records) {
      if (err) throw err;
      console.log(records);
      });
  </code></pre>
  
  <p>In console record is being returned without being updated</p>