Bird
0
0

You want to update an existing item in DynamoDB only if it already exists. Which operation and parameter combination should you use?

hard📝 Application Q8 of 15
AWS - DynamoDB
You want to update an existing item in DynamoDB only if it already exists. Which operation and parameter combination should you use?
AUse <code>put</code> operation with <code>ReturnValues</code> set to ALL_NEW.
BUse <code>update</code> operation with a <code>ConditionExpression</code> that checks attribute_exists on the primary key.
CUse <code>get</code> operation followed by <code>put</code> operation unconditionally.
DUse <code>delete</code> operation with a condition to check item existence.
Step-by-Step Solution
Solution:
  1. Step 1: Identify update operation

    To modify an existing item conditionally, use the update operation.
  2. Step 2: Use ConditionExpression

    Include ConditionExpression: 'attribute_exists(PrimaryKeyName)' to ensure the item exists before updating.
  3. Final Answer:

    Use update operation with a ConditionExpression that checks attribute_exists on the primary key. -> Option B
  4. Quick Check:

    Update with condition ensures item exists [OK]
Quick Trick: Use update with attribute_exists condition [OK]
Common Mistakes:
MISTAKES
  • Using put which overwrites without condition
  • Trying to update without condition expression
  • Using get followed by put causing race conditions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes