title: How does mongodb create database/collection on the fly
body: <p>Mongodb is cool enough to create the database/collection on the fly, if we run a code similar to</p>
  
  <pre><code>db.store.save({a: 789});
  </code></pre>
  
  <p>It automatically creates <code>store</code> collection and add a document to it.</p>
  
  <p>My javascript understanding says it is not possible to call a method on an undefined property of <code>db</code> object. It should have resulted in some kind of error/exception.</p>
  
  <p>I am curious to understand the happenings behind the scene and if there is any helpful link please point me to those. Googling did not help me much.</p>