如何解决mysql queryAsync(promisify pool),直到结果无法完成?

时间:2015-10-27 16:16:37

标签: javascript node.js promise bluebird

我正在使用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);
}

0 个答案:

没有答案