When starting a transaction in TypeORM or even other ORMs or query builders, I've noticed that each query is being sent separately to the database though I know this is using the same connection.
"BEGIN;", "... some SELECT, UPDATE, DELETE queries;", "COMMIT;" - these are all sent as individual queries which **adds to API latency **since each takes a round trip to the DB as it's on another remote server.
How can I send **transactions **with multiple statements as one whole query to the database, in a single round trip? Or is there some other type-safe query builder/ORM that supports this? For context, (1) I do not need to execute some custom JavaScript logic/code between each query. (2) Calling stored procedures is not an option with my specific use case (can't disclose some other details). (3) CTEs (WITH queries) are also not an option since I need the queries to run sequentially. PG documentation states that WITH queries are ran concurrently for those that include data modifying statements.