See also this related thread on the Elixir mailing list https://groups.google.com/forum/#!topic/elixir-lang-talk/ft6...
var Q = require('q'); function getUserFriends(userName) { return Q.nfcall(db.users.findOne, {name:userName}); } function foundOne(user) { return Q.nfcall(db.friends.find, {userId:user.id}); } function foundFriends(friends) { ... } getUserFriends.then(foundOne).then(foundFriends);