_Alfred
"In this the love of God was made manifest among us, that God sent his only Son into the world, so that we might live through him." - 1 John 4:9,10.
MongoDB Shell Bulk Insert Test
By sysadmin - Published: 2016-03-06
How to write a for loop that bulk inserts 1,000 documents at a time, 1000 times, for a total of 1 million documents inserted in the MongoDB shell:
var bulk = db.bulkTest.initializeUnorderedBulkOp();
for (var j = 0; j < 1000; j++ ) {
for (var i = 0; i < 1000; i++ ) {
bulk.insert( { "a" : i, "b" : j } );
}
}
bulk.execute();
See the results: