|
|
|
|
|
by modiho
4686 days ago
|
|
Q has some utility functions around wrapping node style callbacks that make the code a bit shorter and arguably more easy to understand. 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);
|
|