Skip to content

Instantly share code, notes, and snippets.

@mehdishahdoost
Created July 1, 2023 15:20
Show Gist options
  • Select an option

  • Save mehdishahdoost/aeabe3e1a60f7b3795a0adfc8d4352ee to your computer and use it in GitHub Desktop.

Select an option

Save mehdishahdoost/aeabe3e1a60f7b3795a0adfc8d4352ee to your computer and use it in GitHub Desktop.
mongodb-bulk-insertion-scripts
db = db.getSiblingDB('dbname');
insertBulk = function() {
var bulk = db.books.initializeUnorderedBulkOp(); // or we can use db.books.initializeOrderedBulkOp();
for(loop=0;loop<1000;loop++) {
bulk.insert({name: "Moon"});
}
bulk.execute();
}
insertBulk();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment