Why do I need to await a knex.transaction() to begin a transaction. Calling const trx = knex.transaction() should be sufficient. I don't need to tell the database I am starting a transaction until I actually want to read or write data.
e.g., if all I am doing is atomically writing data like
trx('myTable1').insert(data1)
trx('myTable2').insert(data2)
await trx.commit
Under the hood I am trying to create a sql query like
BEGIN
INSERT "myTable1" VALES(...)
INSERT "myTable2" VALES(...)
COMMIT
the const trx = knex.transaction() should create BEGIN
and the await trx.commit should be adding COMMIT, serializing this over the write to the database and awaiting acceptance or rejection from the DB. In my example above, the only the await required should be for the trx.commit()
Thanks