title: Mongoose retun nModified : 1 when no data is updated
body: <p>Trying to understand why/if mongoose is updating my documents even though no data is changed?</p>
  <p>If I save a new document with the query below it will return  this in the console.log(item)</p>
  <pre><code>{ n: 1,
        nModified: 0,
        upserted: [ { index: 0, _id: 5f3d35c386aeb6c6fb35fa79 } ],
        ok: 1 }
  </code></pre>
  <p>Query</p>
  <pre><code>Product.updateOne(
           {productName: product.productName},
           {$set: newProduct},
           {upsert: true}
        ).then((item) =&gt; {
           console.log(item);
      }).catch((e) =&gt; {
          console.log('Insert  error', e);
      });
  </code></pre>
  <p>If i rerun the same query again i get this back. This indicates that the document has been modified but the data is the same, there is no new data that has been inserted.
  <code>{ n: 1, nModified: 1, ok: 1 }</code></p>
  <p>I've noticed if i remove the stores array, delete the document, insert it again and rerun the query I get <code>{ n: 1, nModified: 0, ok: 1 }</code> back in the console.log(item)</p>
  <p>I run the same querys, the same amout of time, but when having an array in the object i get this <code>{ n: 1, nModified: 1, ok: 1 }</code>  and when not having an array a get this <code>{ n: 1, nModified: 0, ok: 1 }</code></p>
  <p>It seems that when having an array the document gets modified regardless if the data is changed.</p>
  <p>Example 1
  Gives <code>{ n: 1, nModified: 1, ok: 1 }</code></p>
  <pre><code>const newProduct = {
            ean: product.ean,
            productName: product.productName,
            lowestPrice: product.productPrice,
            mainCategory: categories.mainCategory,
            group: categories.group,
            subCategory: categories.subCategory,
            subSubCategory: subSubCat,
            stores: [{
              name: &quot;foobar&quot;,
             }],
          };
  </code></pre>
  <p>Example 2
  Gives <code>{ n: 1, nModified: 0, ok: 1 }</code></p>
  <pre><code> const newProduct = {
            ean: product.ean,
            productName: product.productName,
            lowestPrice: product.productPrice,
            mainCategory: categories.mainCategory,
            group: categories.group,
            subCategory: categories.subCategory,
            subSubCategory: subSubCat,
            
          };
  </code></pre>
  <p>Is it me who misunderstands the operation below or whats going on?
  What i want to do is:</p>
  <p>1.insert if the document don't exists based on productName,</p>
  <p>2.if something differs in the document stored in the database and the newProduct, update the document.</p>
  <p>3.If nothing differs, do nothing</p>
  <p>Product model</p>
  <pre><code>const ProductSchema = new Schema({
    ean: String,
    productName: String,
    mainCategory: String,
    subCategory: String,
    group: String,
    subSubCategory: String,
    lowestPrice: Number,
    isPopular: Boolean,
    description: String,
  
    stores: [
      {
        name: String,
        
      },
    ],
  });
  </code></pre>
  <p>Edit: As its pretty hard to explain I created a small repo that shows the issue.</p>
  <p><a href="https://github.com/gameatrix/mongo_array" rel="nofollow noreferrer">https://github.com/gameatrix/mongo_array</a></p>