Last active
March 28, 2017 00:20
-
-
Save evanshortiss/f40493d215225461783d73595574a107 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const mongo = require('rhmap-mongodb'); | |
// First remove anything that might be in the collection | |
mongo.collection('test').remove({}) | |
.then(() => { | |
const start = Date.now(); | |
return doTest(1000) | |
.then(() => { | |
console.log('test complete in %dms', Date.now() - start); | |
process.exit(0); | |
}) | |
.catch((e) => { | |
console.log('test failed', e.stack); | |
process.exit(1); | |
}) | |
}); | |
function doTest (count) { | |
return mongo.collection('test').insert({ | |
count: count | |
}) | |
.then(() => { | |
// Recursively call self until count reaches 0 | |
if (count > 0) { | |
return doTest(--count); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment