How to Use db.query to Access Transaction Data in Drizzle ORM When Using Connection Pool?

In Drizzle ORM, I was using createConnection and performing transactions with trx.create. After creating the transaction, I could use db.query to retrieve the data created within the transaction without any issues. However, after switching to createPool, the same approach doesn’t work. Specifically: After trx.create, the subsequent db.query calls cannot access the data created within the transaction. How can I configure the transaction or connection pool so that I can query the data created during the transaction using db.query? Additional Context: Why am I using db.query instead of trx.query? In my transaction callback, I am using certain functions that interact with the database using db.query instead of trx.query. These functions require direct access to the database connection (db.query), which is why I cannot use trx.query within them. This might not be the best approach, but the architecture was designed this way, and refactoring it seems costly at the moment.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?