When writing transactions in application code you have 2 situations:
Examples (little contrived) A:
B:
it's a little contrived but the point is, in case B, operations 4 and 5 don't need to be in the same transaction as 1. in such a case we want to build a knex query which would produce
BEGIN TRANSACTION INSERT INTO historicalEmailsSent ... SET count FROM emailsSentCount WHERE customer='custId' COMMIT
I'm not sure if knex does this today, when you create a transaction, e.g.
const trx = knex.trasnaction();
await trx('historicalEmailsSent).udpdate(...)
await trx('emailSentCount).update(...)
trx.commit();
my understanding is you will end up making 2 separate network requests to the database, holding the transaction open, when you could have made only one. This is because knex doesn't know if inbetween your first and second transaction, you do someething in your app code which then a later transaction depends upon.
Or am I mistaken?