Joseph_Ebuka
Joseph_Ebuka13mo ago

Assist with mutations

i want to add a document to the database but i want to make sure an exact match of that docment dosent already exist before adding it (i just want to make sure the userId dosent match the userID in an already existing document)
3 Replies
erquhart
erquhart13mo ago
You can read before you write within a mutation and Convex guarantees the relevant db state won't change before the write completes. The mutation is a transaction. Eg., if you query at the beginning of a mutation and at the end of the mutation, you will never get two different results. If the underlying data does change, Convex will rerun the mutation. Results of the mutation won't commit to the db until it can run without any underlying data change.
erquhart
erquhart13mo ago
Mutations | Convex Developer Hub
Mutations insert, update and remove data from the database, check authentication
Joseph_Ebuka
Joseph_EbukaOP13mo ago
thank you @erquhart my problem is resolved

Did you find this page helpful?