Node-mysql连接中的多个查询

我在我的项目中使用node-mysql。 我有一个场景,第二个查询的执行将基于从第一个返回的结果。 例如,首先查询select * from table where user = x; 然后基于存在,我将运行另一个查询。 我正在使用pool.getConnection()。 我可以知道我应该创build两个连接还是使用一个连接?

选项a)

pool.getConnection(function(err, connection) { // Use the connection connection.query( 'SELECT something FROM sometable', function(err, rows) { //store the result here as a var a; connection.release(); }); }); //check var a and start another connection to run the second query? 

选项b)

 pool.getConnection(function(err, connection) { // Use the connection connection.query( 'SELECT something FROM sometable', function(err, rows) { //...based on the result, connection.query(second query) connection.release(); }); }); 

感谢锤子

两个选项都使用一个池,所以你已经使用了多个连接。 所以任何一个选项并不重要,唯一的区别可能是第一个选项可能导致第二个查询不能马上执行,如果整个池在第一个查询完成后被使用。