我正在使用bluebird promises lib
旧代码如下所示:
var sql1 = this.pool.queryAsync("1.sql").get(0);
var sql2 = this.pool.queryAsync("2.sql").get(0);
var sql3 = this.pool.queryAsync("3.sql").get(0);
return Promise.join(sql1, sql2, sql3, function (sql1Result, sql2Result, sql3Result) {
//fetching results..
});
现在我需要取消才能在结果已满时执行查询。 粗略地说:
var commonResult = [];
while(commonResult.length < 20) {
commonResult.push(sqlResult);
}