j10
j10

Reputation: 2261

Cannot read property 'transaction' of undefined

I updated my knex to version 0.16.2 and bookshelf is 0.14.1 but when I use transactions in bookshelf like :

     return  bookshelf.transaction(async function(trx) {
       ... code here
     }

I get following error :

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)

the problem is

const trx = this.client.transaction(container, config); 

in node_modules/knex/lib/util/make-knex.js:56:31 as this.client returns undefined

which is called by :

transaction: function transaction() {
      return this.knex.transaction.apply(this, arguments);
 },

in node_modules/bookshelf/lib/bookshelf.js:24

basically our bookshelf.client returns undefined. Not Sure how to go about fixing this.

Upvotes: 2

Views: 1268

Answers (1)

devius
devius

Reputation: 3016

This was just fixed in Bookshelf 0.14.2: https://github.com/bookshelf/bookshelf/releases/tag/0.14.2

Upvotes: 2

Related Questions