title: Mongoose: tried to set nested object field to primitive value 'null'
body: <p>I have a schema with nested fields e.g.</p>
  
  <pre><code>// model.js
  module.exports = Mongoose.model('Model', new Mongoose.Schema(
      {
          Top: {
              Middle: {
                  Bottom: Number
              }
          }
      },
      {
          strict: 'throw'
      })
  )
  </code></pre>
  
  <p>It is quite rare that all these fields exist, and when a field doesn't exist, the process generating it writes <code>null</code>. I would like to have strict mode set to <code>true</code> but it doesn't seem to like when a field that should contain an Object instead contains <code>null</code>:</p>
  
  <pre><code>// app.js
  const Model = require('./model');
  router.post('/api' , async (req, res) =&gt; {
      const doc = new Model(req.body);
      const result = await doc.save();
      res.json(result);
  })
  
  // test
  axios.post('/api', { Top: { Middle: null }})
  =&gt; ObjectExpectedError: Tried to set nested object field 'Middle' to primitive value 'null' and strict mode is set to throw.
  </code></pre>
  
  <p>Is there any way to circumvent this behaviour? Unfortunately it is not a trivial option to have the process generating the data produce <code>undefined</code> instead of <code>null</code>.</p>