Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
DynamoDB - with AWS SDK
What is wrong with this code? const expr = set({ ':val': 10 }).toString(); const params = { TableName: 'MyTable', Key: { id: '123' }, UpdateExpression: expr, ExpressionAttributeValues: { ':val': 10 } }; Options: A) ExpressionAttributeValues keys must match placeholders in UpdateExpression B) No error, code is correct C) UpdateExpression should not be a string D) Key should be a string, not an object
AExpressionAttributeValues keys must match placeholders in UpdateExpression
BNo error, code is correct
CUpdateExpression should not be a string
DKey should be a string, not an object
Step-by-Step Solution
Solution:
  1. Step 1: Verify placeholder matching

    UpdateExpression uses ':val' and ExpressionAttributeValues provides ':val' key, so they match.
  2. Step 2: Check Key and UpdateExpression types

    Key is an object with partition key, and UpdateExpression is a string, both correct.
  3. Final Answer:

    No error, code is correct -> Option B
  4. Quick Check:

    Matching placeholders and correct types = B [OK]
Quick Trick: Ensure placeholders in expression match keys in ExpressionAttributeValues [OK]
Common Mistakes:
MISTAKES
  • Mismatching placeholder names
  • Passing Key as string instead of object
  • Thinking UpdateExpression must be object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes