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.
Asked
Active
Viewed 298 times
1 Answers
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
-
1Great, this worked for me: `.connection(sequelizeTransaction.connection)` – petabyte Mar 25 '20 at 10:54