title: How to import json into MongoDB using Mongoose
body: <p>I have a few problems with this, which is whats making it tricky, so...</p>
  
  <p>I am using Mongoose and MongoLab, I can store data and retrieve it just fine, but I want a system that allows me to do a base seed of the database.</p>
  
  <p>I have the schemas created for the collections, but none are ran because there is no data, so I can't seem to run a normal mongoimport as the collection isn't yet created.</p>
  
  <p>I want to add something to my node server so that if the collection doesn't exist or is empty, it loads a schema for a collection and then inserts the json for the seed data.</p>
  
  <p>so I have this...</p>
  
  <pre><code>var Club = require('./schemas/Club');
  </code></pre>
  
  <p>I normally use Club.find, or Club.save etc, thats working fine.</p>
  
  <p>I want to just run a save against an array of Objects to the Club collection which it needs to create.</p>
  
  <p>I did look into mongoose-fixture but its not been updated in years, and there is probably a way of doing this without needing so much extra code, as I have the schema defined, and the array of json ready.</p>
  
  <p>This is the success event I listed for when I guess I want to do the check and import.</p>
  
  <pre><code>mongoose.connection.on('open', function () {
    console.log('mongoose.connection.opened');
  });
  </code></pre>
  
  <p>Also, to consider, if I wanted to create two collections, and when it generates the ObjectId() for the items in the first collection, I can imagine wanting to use those in the second collection as a ref.</p>
  
  <p>Just assume Club objects only have one string property for now.</p>
  
  <pre><code>// contents of data/club.json
  [
    { 'name' : 'Barcelona' },
    { 'name' : 'Real Madrid' },
    { 'name' : 'Valencia' }
  ]
  </code></pre>
  
  <p>Any help much appreciated</p>