Hello I have the following JSON in database,
{
recordName : String
amount : Number
approved : Boolean
}
Lets say I have two users issu
Because single document updates are atomic, regardless of the order that your two commands execute, the document will end up as:
{amount : 9999, approved: true, ...}
If the first command executes first, then the second command will override it.
If the second command executes first, then the first command has no effect as approve
is now true
so the update conditions won't match.
What you're (correctly) doing is the well-established optimistic concurrency or "update if current" approach to managing concurrent access.