无法读取未定义的 属性 'transaction'
Cannot read property 'transaction' of undefined
我将我的 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 returns 未定义
调用者:
transaction: function transaction() {
return this.knex.transaction.apply(this, arguments);
},
在node_modules/bookshelf/lib/bookshelf.js:24
基本上我们的 bookshelf.client returns 未定义。不确定如何解决这个问题。
这刚刚在 Bookshelf 0.14.2 中修复:https://github.com/bookshelf/bookshelf/releases/tag/0.14.2
我将我的 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 returns 未定义
调用者:
transaction: function transaction() {
return this.knex.transaction.apply(this, arguments);
},
在node_modules/bookshelf/lib/bookshelf.js:24
基本上我们的 bookshelf.client returns 未定义。不确定如何解决这个问题。
这刚刚在 Bookshelf 0.14.2 中修复:https://github.com/bookshelf/bookshelf/releases/tag/0.14.2