title: mongoose 'minimize' empty nested object
body: <p>I've created a mongoose schema which contains multiple level nested properties. It is here:</p>
  
  <pre><code>var Person = new mongoose.Schema({
      name: String,
      parents: {
          mom: {
              name: String,
              birthYear: Number
          },
          dad: {
              name: String,
              birthYear: Number
          }
      }
  });
  </code></pre>
  
  <p>In my example there can be 2 cases of the document state:</p>
  
  <ul>
  <li>every attributes has to be set in the <code>parents</code> object</li>
  <li>the <code>parents</code> object has to be full empty <code>{}</code></li>
  </ul>
  
  <p>My problem is that if the <code>parent</code> object is empty, the document is stored like this:</p>
  
  <pre><code>{
      name: 'Some Buddy',
      parents: {
          mom: {},
          dad: {}
      }
  }
  </code></pre>
  
  <p>While the expected data should be this:</p>
  
  <pre><code>{
      name: 'Some Buddy'
      parents: {}
  }
  </code></pre>
  
  <p>I've read a lot about <code>minimize: true</code> but it does not serve me a complete solution, because the <code>parents</code> object is not saved at all. So in short I would like to minimize every empty nested attributes (except for top-level attributes).</p>
  
  <p>Do you have any idea how can I solve this?</p>
  
  <p>Thank you!</p>