Does throwing an error in a TX automatically rollback?

From what I read in a similar post, it seems that a failed query within a transaction will automatically rollback the entire transaction. I am curious if this applies to any error that causes the transaction to return a rejected promise? For instance, I am using drizzle-valibot to ensure the values inserted within a transaction match the schema. If it doesn't match, can I just throw new Error() causing a rollback for the entire transaction?
1 Reply
pandareaper
pandareaper13mo ago
Yes indeed. tx.rollback simply throws an Error itself I believe
Want results from more Discord servers?
Add your server