CNode

node-mysql的pool必须使用回调方式?

Ccoffeejs发布于13 年前最后回复13 年前1 回复5507 浏览0 收藏

比如必须这样用? var pool = mysql.createPool(config);

pool.getConnection(function(err, connection) { // Use the connection connection.query( 'SELECT something FROM sometable', function(err, rows) { // And done with the connection. connection.end();

// Don't use the connection here, it has been returned to the pool.

}); });

感觉挺繁琐的。

查看回复

回复 (1)

H
hexie#1·13 年前

封装成查询方法 就好了。每次都写难免由出错的时候

参与回复
登录后即可参与回复。登录