title: How to use Mongoose with a highly dynamic schema MongoDB
body: <p>I want to change the schema of my DB. Right now it's like:</p>
  
  <pre><code>{
     "disp":[
          {
              "quantity":1,
              "date":20141109
          },
          {
              "quantity":1,
              "date":20141110
          },
          {
              "quantity":1,
              "date":20141111
          }
      ]
  }
  </code></pre>
  
  <p>"date" is unique and indexed.
  A schema like this one have a BIG downside for me. I can't update "quantity" for multiple dates in an atomic way so I have to implement <a href="http://docs.mongodb.org/manual/tutorial/perform-two-phase-commits/" rel="nofollow">Two Phase Commits</a> in my app.</p>
  
  <p>I'm testing alternative schemas and I think this one would match my needs</p>
  
  <pre><code>{
     "disp":{
          "20141109": {
              "quantity":1
          },
          "20141110": {
              "quantity":1
          },
          "20141111": {
              "quantity":1
          }
      }
  }
  </code></pre>
  
  <p>This way I can atomically update quantities for more than one date but I wonder how to manage this with a mongoose schema because dates can be added and removed in a highly dynamic way.
  In the collection there will be a lot of document with quantities specified for different dates
  ex. a document can have quantities only for a few dates and another document can have quantities for a couple of years</p>
  
  <p>Is is better to add/remove fields forcing every document to have a date field (default to 0 quantity) or is it better to set <a href="http://mongoosejs.com/docs/guide.html#strict" rel="nofollow">strict</a> to false?
  Are there any downsides I'm not aware of ?</p>