Skip to content

Instantly share code, notes, and snippets.

@orlandov
Created January 28, 2010 19:08
Show Gist options
  • Select an option

  • Save orlandov/289028 to your computer and use it in GitHub Desktop.

Select an option

Save orlandov/289028 to your computer and use it in GitHub Desktop.
#!/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