我要得到我的信息,以打印這樣的:兩個異步環和MySQL查詢在節點JS
這是我到目前爲止有:
connection.query('SELECT `keys`.*,`transaction`.*,`keys`.`id` as kid, `transaction`.`id` as tid FROM `transaction` JOIN `keys` ON `keys`.`id` = `transaction`.`keys_id` WHERE `transaction`.`status_pay`= 1 and `transaction`.`status` = 1').then(function (rows) {
async.each(rows, function (record, next) {
async.each(inventory, function (rec, nex) {
connection.query('UPDATE `transaction` SET `amount_two`= `amount_two` + 1 WHERE `id`= \''+record.tid+'\'').then(function (err, res) {
console.log('3');
});
console.log(rec.id); /// 4317648454 ... etc..
});
});
});
但由於某種奇怪的原因,它看起來像這樣:
在這兩種情況下,eachSeries都會解決這個問題,假設你正確地調用'next'。 –
你能舉個例子嗎?請 – user3458952