Mongodb
To process the mongodb driver, I suggest using then-mongo (disclaimer: I wrote it). This is equivalent to mongojs , with the exception of promises instead of callbacks. It also allows you to consider the "connect" operation as synchronous, immediately returning an object with which you can interact, and just wait for the connection inside. It's very nice that it complies with the official mongodb documentation, so you can just use this documentation to figure out how to use it.
General case
In general, using an API that does not return a promise, and getting what needs to be done should be done using the Promise constructor. eg.
function readFile(filename, enc){ return new Promise(function (fulfill, reject){ fs.readFile(filename, enc, function (err, res){ if (err) reject(err); else fulfill(res); }); }); }
If you use Q, you should:
function readFile(filename, enc){ return q.promise(function (fulfill, reject){ fs.readFile(filename, enc, function (err, res){ if (err) reject(err); else fulfill(res); }); }); }
Helper Methods
Many of the libraries included with Q provide special helper methods for adapting node.js style callback methods to return promises. eg.
var readFile = q.denodeify(fs.readFile);
or promise :
var readFile = Promise.denodeify(fs.readFile);
If you need more information on how to create and use Promise objects in general (and not Q), I would suggest you check out https://www.promisejs.org/ (diclaimer: I wrote this).