O'Reilly logo
  • Patrick S thinks this is interesting:

In MongoDB, if you reference and try to use a collection that doesn't exist, it will automatically be created.

The seedData function will first check to see whether we already have any records in our collection or not. If the collection is empty, a few sample records will be inserted.


Cover of Web Development with MongoDB and Node.js


Collection and Seed data