Created
July 7, 2011 16:23
-
-
Save ralphholzmann/1069899 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
var db = new mongo.Db('myDB', new mongo.Server("localhost", "27017", {})), | |
to = "ralph"; | |
db.open( function( err, p_client ) { | |
// Problem opening the database? | |
if ( err ) { | |
console.log( "db.open: " + err ); | |
} | |
// Open the users collection | |
db.collection( 'users', function( err, collection ) { | |
// Retry if no collection was found | |
if ( err || ( ! "findOne" in collection )) { | |
console.log("db.collection: " + err ); | |
} else { | |
// Let's find our user | |
collection.findOne({ | |
"addresses.localPart" : to | |
}, function( err, doc ) { | |
if ( err ) { | |
console.log( "collection.findOne: " + err ); | |
} | |
console.log( "doc: " + doc ); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment