Below is my code
var mongodb = require('mongodb');
var MongodbClient = mongodb.MongoClient;
MongodbClient.connect('mongodb://localhost/test', function(err, db) {
if(!err){
console.log("We are connected!!");
}
var contact = db.collection('contact');
contact.update({name: "Fred"}, {$set: {tel:'09088oooxxaa'}}, function(err,r) {
if(err){
console.log("Update err");
}
else{
console.log('Update success');
console.log(r.name);
}
});
contact.find({name: "Fred"}).toArray(function(err, results) {
console.log(results[0]);
});
});
I can get the result array by using find() method in the end of this code.
However, I would like to know is any way I can get same results array in update function code by callback?
I tried to worte "console.log(r.name) in update code but show undefined