Created
January 28, 2010 19:08
-
-
Save orlandov/289028 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env node | |
| process.mixin(GLOBAL, require('mjsunit')); | |
| require.paths.push("lib"); | |
| var mongodb = require( 'mongodb' ); | |
| var sys = require( 'sys' ); | |
| var mongo = new mongodb.MongoDB(); | |
| jjj = JSON.stringify | |
| mongo.addListener('connection', function( ) { | |
| var test = mongo.getCollection('widgets'); | |
| test.remove(); | |
| var i = 1000; | |
| function doInserts() { | |
| if (!i--) return; | |
| test.insert( { i: i } ); | |
| process.nextTick(arguments.callee); | |
| } | |
| doInserts(); | |
| }); | |
| mongo.addListener('close', function() { | |
| sys.puts("Tests done!"); | |
| }); | |
| mongo.connect({ | |
| hostname: '127.0.0.1', | |
| port: 27017, | |
| db: '__node_mongodb_test' | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment