【发布时间】:2014-05-12 01:10:51
【问题描述】:
使用 bluebird q,我有这个:
var myBill
db.getBillAsync().then(function (bill) {
myBill = bill
return users.find_user_by_idAsync(bill.user_id)
}).then(function (user) {
myBill.user_name = user.name
console.log(myBill)
})
上面代码的目的是获取用户名并将其添加到账单中,这很好用,现在如果我有一个账单列表,如何获取所有账单的名称并分配给 myBills?使用循环?还是蓝鸟有其他方法?
var myBills
db.getBillsAsync().then(function (bills) {
myBills = bills
return users.find_user_by_idAsync(bill.user_id) ?
}).then(function (user) {
?
})
【问题讨论】:
标签: node.js promise q bluebird