simple test to import a million records into a mongodb using node
You need a data file. Run the following command to generate the test.json
json file.
$ node generate-data.js
If you would like to customize the data file you can do so by adding the following command line arguments: --filename
and --size
--filename
specifies a filename for the data document. default value istest.json
.--size
specifies the number of documents to create. default value is1000000
.
$ node generate-data.js --size 100 --filename small-test.json
What the magic happen!
$ node index.js
If you have customized the data file, would like to specify the database and or collection, use the following command line arguments: --database
, --collection
, --filename
--database
specifies the database used during the import. defaults tobig-mongo-test
--collection
specifies the collection used during the import. defaults tobigdata
--filename
specifies a filename for the data document. default value istest.json
.