【发布时间】:2017-05-26 02:29:28
【问题描述】:
我目前使用knexjs.org,承诺代替常规回调,并使用池连接进行 SQL 查询。第一次,它运行平稳。但现在我通常会面临池连接错误。代码是这样的
knex('user_detail')
.select('id','full_name','phone','email')
.where('id', id_user)
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
})
但现在我通常会收到错误连接超时和错误池连接。首先为什么会出错可能是因为我没有释放连接,但是我有这样的代码,
knex('user_detail')
.select('id','full_name','phone','email')
.where('id', id_user)
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
})
.finally(() => {
knex.destroy()
})
它在第一次尝试时有效,但在第二次尝试时失败并收到错误There is no pool defined on the current client,有时还会出现错误The pool is probably full
有人可以向我解释发生了什么以及我如何解决它吗?谢谢。
【问题讨论】:
标签: mysql node.js promise connection-pooling knex.js