node-mysql multiple statements in one query, execute conditionally on response from each

Deadly 提交于 2020-03-05 02:07:11

问题


I want to execute multiple queries in one API call, but I only want to execute them conditionally based on the response of the previous one. How can I go about implementing this?

I've seen that I can do something like below to execute multiple queries.

connection.query('SELECT * ...; SELECT * ...', [1, 2], function(err, results) {
   if (err) throw err;
});

But how do I await the response of the first before conditionally executing the second?

来源:https://stackoverflow.com/questions/60230245/node-mysql-multiple-statements-in-one-query-execute-conditionally-on-response-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!