Created
August 8, 2012 04:18
-
-
Save darkyen/3292002 to your computer and use it in GitHub Desktop.
readReference error with node-mongodb-native
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
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