Bird
0
0

You run this code to add an item to DynamoDB:

medium📝 Debug Q7 of 15
DynamoDB - with AWS SDK
You run this code to add an item to DynamoDB:
const command = new PutItemCommand({ TableName: 'Orders', Item: { orderId: '001', amount: 100 } });
await client.send(command);

Why does it throw an error?
APutItemCommand requires a callback function.
BThe TableName 'Orders' is misspelled.
CThe client was not initialized with a region.
DThe Item attributes lack DynamoDB data types like { S: '001' }.
Step-by-Step Solution
Solution:
  1. Step 1: Review Item format

    DynamoDB SDK requires attribute values to specify data types explicitly, e.g., { S: 'string' } or { N: 'number' }.
  2. Step 2: Identify error cause

    The provided Item uses plain JavaScript values without type wrappers, causing the error.
  3. Final Answer:

    The Item attributes lack DynamoDB data types like { S: '001' }. -> Option D
  4. Quick Check:

    Item attributes must include data types [OK]
Quick Trick: DynamoDB Item attributes require explicit data types [OK]
Common Mistakes:
MISTAKES
  • Assuming plain JS objects are accepted as Item
  • Ignoring required region configuration
  • Thinking PutItemCommand needs callbacks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes