Writing data · Lesson 10 of 20
Claim it, or fail
A ConditionExpression lets a write happen only if the data still allows it.
Why
A PutItem normally overwrites whatever shares its key. A ConditionExpression guards it: the write happens only if the condition holds at the instant it runs, atomically, with no read-first race for two callers to lose.
Claim a free callsign and attribute_not_exists(pk) passes. Claim one alice already holds and the engine rejects the write with a ConditionalCheckFailedException, leaving her record untouched. Read it back to confirm. This is how you register something exactly once.
A condition turns a blind write into a guarded one. attribute_not_exists is a first-writer-wins claim, enforced at write time.
attribute_not_exists(pk) means 'only if nobody holds this'. The callsign is free, so the write lands.
Run an operation to see the raw engine response.