
var MongoClient = require('mongodb').MongoClient,
    fs = require('fs');

var datafile = './data/capacityregions.json';
var data = JSON.parse(fs.readFileSync(datafile));
console.log(data[0], data.length);

MongoClient.connect('mongodb://127.0.0.1:27017/regions', function(err, db) {

    if(err) throw err;

    var collection = db.collection('regions');

    data.forEach(function (element, index) {
        collection.insert(element, function(err, docs) {
            //console.log('hello', index);
        });
    });
});

var MongoClient = require('mongodb').MongoClient,
    fs = require('fs');

var datafile = './data/capacityregions.json';
var data = require(datafile);
MongoClient.connect('mongodb://127.0.0.1:27017/regions', function(err, db) {

    if(err) throw err;

    var collection = db.collection('regions');
	collection.insert(data,function(err,asd){
		console.log('err',err);
		db.close();
	})
});


fix json2mongo.