Skip to content

Instantly share code, notes, and snippets.

@darkyen
Created August 8, 2012 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkyen/3292002 to your computer and use it in GitHub Desktop.
Save darkyen/3292002 to your computer and use it in GitHub Desktop.
readReference error with node-mongodb-native
var mongodb = require( 'mongodb' ),
Server = mongodb.Server,
Db = mongodb.Db,
MongoModule = {};
MongoModule.setup = function() {
// Initialize the db connection
var client = new Db( 'tartempion',
new Server(
'127.0.0.1',
27017,
{
auto_reconnect: false,
poolSize: 4
}
)
);
client.open( function( err, db ) {
if ( err ) throw err;
MongoModule.db = db;
MongoModule.collection( 'pages', function( e, p ) {
if ( e ) throw e;
console.log( p );
});
console.log( 'Database driver loaded.' );
});
};
MongoModule.collection = function() {
this.db.collection.apply( this.db , arguments );
};
MongoModule.setup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment