I am fairly new to NodeJS and MongoDB
I am trying to do a very basic stuff but it does not seem to be working.
I am sure that I am missing something somewhere.
Basically, I am trying to find a user from the DB based on the id.
Here is my code:
function findUser(id, cb) {
MongoClient.connect(cs, function(err, db) {
var col = db.collection('users');
col.findOne({ _id: id }, function(err, user) {
// Value of user here is always null
// However, if I manually check the database,
// I can clearly see that the user with the
// same id does exists.
return cb(err, user);
});
});
}