我目前使用knexjs.org,承诺,而不是常规的回调并使用SQL查询池连接。第一次,它运行平稳。但是现在我通常面对游泳池连接错误。该代码是这样的knexjs答应释放池连接
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
能有人向我解释这是怎么回事,我该如何解决呢?谢谢。