Burd
Burd2y ago

idempotent mutation

Hey folks, is there any way to make an idempotent mutation? I want to update a row documents based on the document_id (custom column), if not there, create a new one. Couldn't find anything in the docs, any hints?
4 Replies
ballingt
ballingt2y ago
You can do this the natural way: query the database for the row and use an if statement to create it if it does not exist, else update it.
Burd
BurdOP2y ago
Dang, is that simple? that's awesome! Thanks Tom!
ballingt
ballingt2y ago
It's all in a transaction (assuming you're doing this logic in a Convex mutation function)
Burd
BurdOP2y ago
I am, yes! Appreciate you Tom!

Did you find this page helpful?