title: Mongo $set function is resetting default value
body: <p>I have the following collection in MongoDB:</p>
  
  <pre><code>shop: {
      products: [{
       (...)
          _id: {
              type: mongoose.Schema.Types.ObjectId,
              ref: 'Product',
              unique: true
          },
          dateAdded: {
              type: Date,
              default: Date.now,
              required: true
          },
          dateModified: {
              type: Date,
              default: Date.now,
          },
      }]
  }
  </code></pre>
  
  <p>Which, according to their names, contains the date when the product is created an when he is updated.</p>
  
  <p>I'm updating a product like this:</p>
  
  <pre><code>Shop.findOneAndUpdate({
      _id: shopId,
      "products._id": prod._id
  },
  {
      "$set": {
          "products.$": prod
      }
  },
  {
      new: true,
      upsert: true
  })
  </code></pre>
  
  <p>'prod' does not contains all the fields of the product, so I use $set to only save the fields which I provide instead of cleaning those.</p>
  
  <p>'prod' does contain an _id field and an dateModified value, but not an dateAdded, but that field is actually updated with the Date.now value, which leads to that dateAdded and dateModified always has the same value.</p>
  
  <p>How can I fix this? dateAdded must only be filled when he is empty, but since I'm updating here, you can assume that there is an value for that field.</p>
  
  <p><strong>Edit for duplicate mark</strong>
  This question is not about the _id field, that is working fine and only added to make this question more clearer. It's about the default value of an different field (dateAdded)</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Following the marked questions I changed my query to this:</p>
  
  <pre><code>Shop.update({
      _id: shopId,
      "products._id": prod._id
  },{
      "$set": {
          "products.$": prod
      }
  },{
      new: true
  })
  </code></pre>
  
  <p>So, I changed the <code>findOneAndUpdate()</code> to <code>update()</code> and removed the <code>upsert:true</code> option, but still the dateCreated is updated with <code>date.now()</code>. Did I miss something?</p>