【发布时间】:2023-03-26 16:40:01
【问题描述】:
我将 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 返回 undefined
由 :
调用transaction: function transaction() {
return this.knex.transaction.apply(this, arguments);
},
在 node_modules/bookshelf/lib/bookshelf.js:24 中
基本上我们的 bookshelf.client 返回 undefined。不知道如何解决这个问题。
【问题讨论】:
-
如果我将 knex 降级到 0.14.6(我以前的版本),我就能让它工作
-
是的,Bookshelf 还不兼容 knex 0.15+。
-
@devius : 知道书架何时能与最新版本的 knex 兼容。
标签: knex.js bookshelf.js