Writing data · Lesson 11 of 20
No silent clobbers
A version check lets an update land only if nobody changed the item since you read it.
Why
Two people open the same itinerary. Without a guard, the second to save silently overwrites the first. A version attribute fixes that: every write carries the version it expects and bumps it atomically with ADD.
Update with the version you read and it lands, taking version from 3 to 4. Run the stale update and the condition version = 3 no longer holds, so the engine rejects it with a ConditionalCheckFailedException. The stale writer must re-read and retry. No update is ever lost.
A version attribute plus a condition gives optimistic concurrency: a stale write bounces instead of silently overwriting a newer one.
The Kyoto itinerary is at version 3. You must know the version before you can lock on it.
Run an operation to see the raw engine response.