1

I have a codebase using the sequelize ORM and want to move to Objection.js ORM. Is there a way to reuse a transaction started in sequelize with Objectionjs? So that I could migrate iteratively instead of having to rewrite everything at once.

petabyte
  • 1,487
  • 4
  • 15
  • 31

1 Answers1

1

If you can get knex transaction that is started by Sequelize, you can pass that to objection.js Model.query(trx).

If Sequelize doesn't use knex transactions under the hood, then if you can get raw database connection that is used by Sequelize transaction you can use .connection(rawConnection) query builder method to define, which raw connection to use for knex queries.

However you should not use transaction feature of both libraries to prevent starting / committing the transaction multiple times.

People who knows Sequelize may complete this answer by telling if/how it allows getting th connection used by Sequelize transaction.

Mikael Lepistö
  • 18,909
  • 3
  • 68
  • 70