Created
November 2, 2017 14:12
-
-
Save musukvl/997f1eca1f8f8fd42d3ef8ca7903bf4d to your computer and use it in GitHub Desktop.
MongoDB function to create 100 000 documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.system.js.save({ | |
_id: "test", | |
value: function () { | |
var start = new Date(); | |
for (var i = 1; i <= 100000; i++) { | |
db.getCollection('log').insert({ | |
"key": (new ObjectId()).toString(), | |
"data": "some random data: " + (new ObjectId()).toString(), | |
"updated_date": new Date() | |
}) | |
} | |
return new Date() - start; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment