Bird
0
0

Identify the error in this code snippet: const expr = set({ ':val': 5 }); const updateParams = { UpdateExpression: expr }; Options: A) UpdateExpression must be a string, not an object B) ':val' should be '#val' C) set() cannot accept objects D) No error, code is correct

medium📝 Debug Q6 of 15
DynamoDB - with AWS SDK
Identify the error in this code snippet: const expr = set({ ':val': 5 }); const updateParams = { UpdateExpression: expr }; Options: A) UpdateExpression must be a string, not an object B) ':val' should be '#val' C) set() cannot accept objects D) No error, code is correct
ANo error, code is correct
B':val' should be '#val'
Cset() cannot accept objects
DUpdateExpression must be a string, not an object
Step-by-Step Solution
Solution:
  1. Step 1: Check set() return type

    set() returns an expression object, not a string directly.
  2. Step 2: Understand UpdateExpression requirement

    UpdateExpression expects a string, so passing the object causes an error.
  3. Final Answer:

    UpdateExpression must be a string, not an object -> Option D
  4. Quick Check:

    UpdateExpression needs string = A [OK]
Quick Trick: Convert expression object to string before assigning UpdateExpression [OK]
Common Mistakes:
MISTAKES
  • Passing expression object directly without toString()
  • Confusing placeholders with attribute names
  • Assuming set() only accepts strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes