Database transactions #526
Replies: 36 comments 44 replies
-
Need Transactions, BEGIN / COMMIT / ROLLBACK cannot find it anywhere in the docs? |
Beta Was this translation helpful? Give feedback.
-
me too. I Do Need Transactions, BEGIN / COMMIT / ROLLBACK like: await supabase.transaction( supabase.from(...).update(...) When I ask the supabase.io tech team, I didn't get the solution for solving this problem and I only get suggest for using rpc. But I don't know how to really construct the rpc function for multiple database actions, including insert to the first table by multiple rows and then update the second table for different rows with different id and then update the third table for updating the data by key, if there is any error occurred during the THREE TABLEs transaction then ROLLBACK, otherwise COMMIT the transaction. Any solution or suggestion for writing the correct rpc function to handle the multiple tables' operations(insert, update, ...) in one transaction which can make sure the data consistency? Need help!! |
Beta Was this translation helpful? Give feedback.
-
I find firebase's transactions and batched writes APIs to be very useful and developer-friendly. It would be fantastic to see something similar integrated into supabase. As it stands, this is a huge sticking-point for me when deciding to use supabase vs alternatives. Learning and writing RPCs each time we want to do a simple batched write / atomic transaction is not fun. Firebase docs on transactions / batched writes: https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes Example of firebase batching API from their docs: import { writeBatch, doc } from "firebase/firestore";
// Get a new write batch
const batch = writeBatch(db);
// Set the value of 'NYC'
const nycRef = doc(db, "cities", "NYC");
batch.set(nycRef, {name: "New York City"});
// Update the population of 'SF'
const sfRef = doc(db, "cities", "SF");
batch.update(sfRef, {"population": 1000000});
// Delete the city 'LA'
const laRef = doc(db, "cities", "LA");
batch.delete(laRef);
// Commit the batch
await batch.commit(); Original comment on other thread: https://github.com/supabase/supabase-js/issues/87#issuecomment-999147766 |
Beta Was this translation helpful? Give feedback.
-
Supabase-cli is a step in the right direction in a CI/CD workflow but to suggest using RPC functions to get transactions is shamelessly trite. |
Beta Was this translation helpful? Give feedback.
-
Bumping this because it would be nice to have this as a feature instead of having postgres rpc functions that fire with no knowledge if it failed or not. |
Beta Was this translation helpful? Give feedback.
-
This makes me sad too. I hope the Supabase devs will prioritize this. Another strike against Supabase in seeing if I can use it in my production environment for my company. :( |
Beta Was this translation helpful? Give feedback.
-
Wanted to share a relatively new option to transactions in Supabase, and while this is not an ideal alternative to client transactions, it could be better in some ways than writing stored procedures: with release of Supabase Edge Functions - there is a way to connect to Postgres directly: https://supabase.com/docs/guides/functions/connect-to-postgres thus have access to transactions API. So instead of writing PL/pgSQL you can write JS/TS (or even Dart) and potentially reuse some of your code. |
Beta Was this translation helpful? Give feedback.
-
Just following up here with my two cents after using transactions via
I'd wonder if @steve-chavez and team have made progress on the hard problem of doing stateful transactions through a stateless API? |
Beta Was this translation helpful? Give feedback.
-
How is this not a priority feature? |
Beta Was this translation helpful? Give feedback.
-
Can we please make this feature happen, it's essential for backend development. Not sure why it hasn't been developed already? |
Beta Was this translation helpful? Give feedback.
-
hello supabase team, i hope you are doing well if supabase implements this feature, it will hands down be the only BaaS i'll use till i die! Thanks |
Beta Was this translation helpful? Give feedback.
-
Any update about this feature? |
Beta Was this translation helpful? Give feedback.
-
Hello... anyone here?.... This discussion has gone silent 😮💨 , is there an ETA for this feature?? Thanks for your hard work, we appreciate the effort that went into supabase. |
Beta Was this translation helpful? Give feedback.
-
In a need of transaction support too. |
Beta Was this translation helpful? Give feedback.
-
Hello supabase team! Any updates on this feature? |
Beta Was this translation helpful? Give feedback.
-
This just came across my YouTube feed... Supabase is able to perform transactions now. The video goes over creating transactions and also ways of using the Supabase dashboard turn it into a Postgres function: https://youtu.be/xUeuy19a-Uw |
Beta Was this translation helpful? Give feedback.
-
Has anyone else in this thread experienced this error trying to run transactions via Kysley according to the tutorial from supabase: https://supabase.com/docs/guides/functions/kysely-postgres I'm guessing this is a new error/feature of the connection pooler? |
Beta Was this translation helpful? Give feedback.
-
You can connect using drizzle-orm as a workaround: https://orm.drizzle.team/docs/transactions |
Beta Was this translation helpful? Give feedback.
-
Need transactions ┊┊┊┊⋆ ✧ · ✧ ✵ |
Beta Was this translation helpful? Give feedback.
-
@joshnuss the referenced issue is nearly ten bloody years old we're customers and don't have a key component of extremely common database operations. there should be an expectation set here (even if that's "ain't gonna happen") |
Beta Was this translation helpful? Give feedback.
-
Update: we plan to support transactions. Follow issue PostgREST/postgrest#286 for the latest.
It would be handy if there was a way to execute multiple operations within a transaction. Similar to Ecto.Multi.
Maybe something like:
Would reduce the number of situations where a postgres function is needed.
Beta Was this translation helpful? Give feedback.
All reactions