title: Document not updated in findOneAndUpdate
body: <p>I have a post route that receives data from a PUT request in an express app that aims to update a mongoose document based on submitted form input. The &quot;Base&quot; model is <code>Profile</code>, and I have two <a href="https://mongoosejs.com/docs/discriminators.html" rel="nofollow noreferrer">discriminator</a> models <code>Helper</code> and <code>Finder</code> that conditionally add fields to the <code>Profile</code> schema (see below for details).</p>
  <p>Thus, <code>req.body.profile</code> will contain different fields depending on the discriminator it's associated with, but will always contain the fields (<code>username</code>, <code>email</code> <code>city</code>, <code>accountType</code>) present in the &quot;base&quot; model, <code>Profile</code>.</p>
  <p>Before I send my PUT request, an example of a document in <code>Profile</code> looks like this:</p>
  <pre><code>{ jobTitle: '',
    lastPosition: '',
    email: '',
    city: '',
    accountType: 'helper',
    _id: 5c77883d8db04c921db5f635,
    username: 'here2help',
    __v: 0 }
  </code></pre>
  <hr />
  <p>This looks good to me, and suggests that the model is being created as I want (with base fields from <code>Profile</code>, and those associated with the <code>Helper</code> model - see below for models).</p>
  <p>My POST route then looks like this:</p>
  <pre><code>router.put(&quot;/profile/:id&quot;, middleware.checkProfileOwnership, function(req, res){
  
      console.log(req.body.profile);
  
      Profile.findOneAndUpdate(req.params.id, req.body.profile, function(err, updatedProfile){
  
          if(err){
              console.log(err.message);
              res.redirect(&quot;/profile&quot;);
          } else {
              console.log(updatedProfile);
              res.redirect(&quot;/profile/&quot; + req.params.id);
          }
  
      });
  });
  </code></pre>
  <p>The information I receive from the form (<code>console.log(req.body.profile)</code>) is what I expect to see:</p>
  <pre><code>{ accountType: 'helper',
    username: 'here2help',
    email: 'helpingU@me.com',
    city: 'New York',
    jobTitle: 'CEO',
    lastPosition: 'sales rep'}
  </code></pre>
  <p>However, after updating the document with <code>req.body.profile</code> in <code>Profile.findOneAndUpdate()</code>, I do not see my returned document updated:</p>
  <p><code>console.log(updatedProfile)</code></p>
  <pre><code>{ jobTitle: '',
    lastPosition: '',
    email: 'helpingu@me.com',
    city: 'New York',
    accountType: 'helper',
    _id: 5c77883d8db04c921db5f635,
    username: 'here2help',
    __v: 0 }
  </code></pre>
  <p>So, the fields that are defined in my 'Base' model (ie those defined in <code>ProfileSchema</code> - see below) are being updated (e.g. <code>city</code>), but those that are in my discriminators are not - see below.</p>
  <p>The updated information is clearly present in <code>req</code>, but is not propagated to the <code>Profile</code> model - <strong>How can this be?</strong></p>
  <p>I've also tried using <code>findByIdAndUpdate</code> but I get the same result.</p>
  <p>Here are the Schemas I'm defining:</p>
  <p><strong>Profile</strong> - my &quot;base&quot; schema:</p>
  <pre><code>var mongoose = require(&quot;mongoose&quot;);
  var passportLocalMongoose = require(&quot;passport-local-mongoose&quot;);
  
  var profileSchema = new mongoose.Schema({ 
      username: String,
      complete: { type: Boolean, default: false },
      email: { type: String, default: &quot;&quot; },
      city: { type: String, default: &quot;&quot; }
  }, { discriminatorKey: 'accountType' });
  
  profileSchema.plugin(passportLocalMongoose);
  
  module.exports = mongoose.model(&quot;Profile&quot;, profileSchema);
  </code></pre>
  <p><strong>Finder</strong></p>
  <pre><code>var Profile = require('./profile');
  
  var Finder = Profile.discriminator('finder', new mongoose.Schema({
      position: { type: String, default: &quot;&quot; },
      skills: Array
  }));
  
  module.exports = mongoose.model(&quot;Finder&quot;);
  </code></pre>
  <p><strong>Helper</strong></p>
  <pre><code>var Profile = require('./profile');
  
  var Helper = Profile.discriminator('helper', new mongoose.Schema({
      jobTitle: { type: String, default: &quot;&quot; },
      lastPosition: { type: String, default: &quot;&quot; }
  }));
  
  module.exports = mongoose.model(&quot;Helper&quot;);
  </code></pre>
  <p>This is my first attempt at using <a href="https://mongoosejs.com/docs/discriminators.html" rel="nofollow noreferrer">discriminators</a> in mongoose, so it's more than possible that I am setting them up incorrectly, and that this is the root of the problem.</p>
  <p>Please let me know if this is unclear, or I need to add more information.</p>