我将knex更新为版本0.16.2,书架为0.14.1,但是当我在书架中使用事务时:
return bookshelf.transaction(async function(trx) {
... code here
}
我收到以下错误消息:
TypeError: Cannot read property 'transaction' of undefined
at Object.transaction (/Users/abc/Desktop/proj/backend/node_modules/knex/lib/util/make-knex.js:56:31)
at Object.transaction (/Users/abc/Desktop/proj/backend/node_modules/bookshelf/lib/bookshelf.js:249:36)
at Function.addAction (/Users/abc/Desktop/proj/backend/models/User.js:180:30)
问题是
const trx = this.client.transaction(container, config);
在node_modules / knex / lib / util / make-knex.js:56:31中,因为this.client返回未定义
,由调用:
transaction: function transaction() {
return this.knex.transaction.apply(this, arguments);
},
在node_modules / bookshelf / lib / bookshelf.js:24
中基本上,我们的bookhelf.client返回undefined。不确定如何解决此问题。