简体   繁体   中英

Knex event on transaction success

I have a function that takes a transaction object as an argument. Can this function subscribe to an event that fires when the transaction is commited?

function createUser (data, trx) {
  trx.on('success', .. )
  return User.create(data, { transacting: trx })
}

I never found better solution. But transaction is event emmiter so you can override default knex functions to emit your custom event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM