【发布时间】:2021-03-04 13:14:11
【问题描述】:
使用 async.js,我可以用处理程序定义承诺(我知道它的唯一功能),并且它给了我与不同处理程序的多态性,结果也是分离的。 我可以在蓝鸟中做到这一点吗?
async.parallel({
cityPromises: (cb)=>{
City.find({
areaId: {$in:locations.city}
}).then(result=> cb(null,result))
},
townPromises: (cb)=>{
Town.find({
areaId: {$in:locations.town}
}).then(result=>cb(null,result))
},
quarterPromises: (cb)=>{
Quarter.find({
areaId: {$in:locations.quarter}
}).then(result=>cb(null,result))
}
},(err,promises)=>{
let {cityPromises, townPromises, quarterPromises} = promises
})
【问题讨论】:
标签: javascript node.js bluebird async.js