title: Dynamic sub-doc using Mongoose
body: <p>I'm having a dynamic data model, with couple of static field and the rest are dynamic. e.g.</p>
  
  <pre><code>var item1 = {
      title:'Door',
      price: 30,
      color:{selected:'blue', options:['blue', 'red']}, // dynamic
      material:{selected:'wood', options:['iron', 'wood', 'plastic']}
  }
  
  var item2 = {
      title:'T-Shirt',
      price: 5,
      color:{selected:'green', options:['blue', 'green']}, // dynamic 
      size:{selected:'XL', options:['XL', 'L']} // dynamic
  }
  </code></pre>
  
  <p>The fields that are marked as dynamic are not know on schema definition and new once can appear dynamically.
  The schema I created looks like this:</p>
  
  <pre><code>var itemSchema = mongoose.Schema({
      title: String,
      price: Number
  });
  </code></pre>
  
  <p>It seems like Mongoose stores the dynamic fields but on 'find' these fields return as blobs and toJSON()/toObject() drop them. Is there a way to convert them back to sub-docs?</p>