Aguiarti
Aguiarti12mo 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
ballingt12mo 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.
Aguiarti
AguiartiOP12mo ago
Dang, is that simple? that's awesome! Thanks Tom!
ballingt
ballingt12mo ago
It's all in a transaction (assuming you're doing this logic in a Convex mutation function)
Aguiarti
AguiartiOP12mo ago
I am, yes! Appreciate you Tom!

Did you find this page helpful?