I keep getting an error in regards to querying MongoDB:
var MongoClient = require('mongodb').MongoClient;
//assert = require('assert');
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the Server
MongoClient.connect(url, function(err, db) {
//assert.equal(null, err);
if(err)
throw err;
else{
console.log("Connected correctly to server");
var cursor = db.collection('documents').find({'_id':'01'});
cursor.forEach(function(err,doc) {
if(err){
throw err;
} else{
console.log(doc);
}});
db.close();
}});
The error I am getting is this.
process.nextTick(function(){ throw err;});
[object Object]
Any help is appreciated! Thanks.