0
votes

I would like to know if Azure documentDB provides conditional write? I mean do the write operation when some condition meets.

For example, if I have several resources in DB, I want to delete a resource when at least 2 resources in the DB. It seems the the document saying to check if etag matches. But what if in a case when there are at least 3 resources in the db, user1 tries to delete one resource with etag version1, but user2 tries to add a resource and updated the etag. Then the delete operation will fail.

1
Which is the nature of the condition? - Matias Quaranta
I am sorry what do you mean by nature? - bunny

1 Answers

0
votes

What you describe in your question is actually a question of consistency i think.About the replace consistency,you could set If-Match property in the header which is used to make operation conditional for optimistic concurrency. That is, the document is updated only if the specified etag matches the current version in the database. The value should be set to the etag value of the resource.

Besides, there should be no such built-in mechanism based on my knowledge.