Rollback transaction

Lladal14/13/2023
Hi, I'm trying to figure out if it's possible to intentionally rollback a transaction, the idea is that if one insert into the database ends with certain return value, the whole transaction should end and the insert rolled back. Knex has trx.rollback on the callback parameter, but I couldn't find anything like that on Kysely, am I missing something or is this not yet implemented?
Solution
Lladal14/13/2023
await sql<void>`rollback`.execute(trx)

Okay I was doing raw sql badly, this does work at least
Kkoskimas4/13/2023
If you throw an error from the transaction callback, the transaction will be rolled back
Kkoskimas4/13/2023
Ugh, there's no way to change the solution. The marked solution is wrong and you shouldn't do that. You'll end up with a rollback and another rollback/commit once the transaction callback finishes.
Lladal14/17/2023
Tried to change the solution to yours, personally I still feel like the interface is missing, as ending the transactions by throwing an exception (which has to be caught as it's rethrown) is not the best solution for query builder.
IIgal4/17/2023
Hey ๐Ÿ‘‹

We've had this in mind, and are considering an alternative API: https://github.com/kysely-org/kysely/issues/257
Lladal14/18/2023
Awesome, thanks for the reply ๐Ÿ™‚ We really like Kysely here and really like the direction you're taking it so looking forward to it