I want to use MongoDB with Node.js and in the official documents it is suggesting to use callbacks. Now, I know that it is just a matter of preference, but I really prefer using promises.
I have tried the following:
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017/example';
MongoClient.connect(url).then(function (err, db) {
console.log(db);
});
And the result is undefined. In that case it seems this is not the way to do so.
Can you help me?