Transactions in Edge Functions
Hello everyone!
I was wondering if there's any way to write an Edge Function that behaves like a transaction.
I do have logic in my Database Functions and what I really find valuable of this way is that if any operation inside that function fails; the entire transaction fails and "reverse" any other writes to the database, ensuring that I perform an atomic operation once calling that RPC.
On the other hand, what I don't enjoy a lot of this is that I need to write all of that logic in pgplsql, I'll prefer to have it written in TypeScript. But as long as I understand, the Edge Functions doesn't behave like a transaction when I have multiple operations inside (eg. a couple of inserts and updates), if any of these fails, the others that succeed will not rollback, ending with inconsistent data and undesired results.
So, is there any way to this approach, or any other recommendation? Thanks a lot!
I was wondering if there's any way to write an Edge Function that behaves like a transaction.
I do have logic in my Database Functions and what I really find valuable of this way is that if any operation inside that function fails; the entire transaction fails and "reverse" any other writes to the database, ensuring that I perform an atomic operation once calling that RPC.
On the other hand, what I don't enjoy a lot of this is that I need to write all of that logic in pgplsql, I'll prefer to have it written in TypeScript. But as long as I understand, the Edge Functions doesn't behave like a transaction when I have multiple operations inside (eg. a couple of inserts and updates), if any of these fails, the others that succeed will not rollback, ending with inconsistent data and undesired results.
So, is there any way to this approach, or any other recommendation? Thanks a lot!