Challenge - 5 Problems
Document Client Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this DynamoDB DocumentClient get operation?
Consider a DynamoDB table named Users with a primary key
userId. The table contains an item with userId = '123' and name = 'Alice'. What will be the output of the following DocumentClient get call?DynamoDB
const AWS = require('aws-sdk'); const docClient = new AWS.DynamoDB.DocumentClient(); const params = { TableName: 'Users', Key: { userId: '123' } }; docClient.get(params).promise().then(data => console.log(data));
Attempts:
2 left
💡 Hint
The get operation returns a single item inside the 'Item' property.
✗ Incorrect
The DocumentClient get method returns an object with an 'Item' property containing the retrieved item. It does not return 'Items' or 'Count' for a single get.
📝 Syntax
intermediate2:00remaining
Which option correctly updates an attribute using DocumentClient update method?
You want to update the attribute
age to 30 for the item with userId = '123' in the Users table. Which of the following params objects is syntactically correct for DocumentClient update?Attempts:
2 left
💡 Hint
ExpressionAttributeValues keys must start with a colon and match placeholders in UpdateExpression.
✗ Incorrect
Option D correctly uses ':a' as a placeholder in both UpdateExpression and ExpressionAttributeValues with a numeric value 30. Option D misses the colon in UpdateExpression. Option D misses the colon in ExpressionAttributeValues key. Option D uses a string '30' instead of number 30 which may be valid but is not the intended numeric update.
❓ optimization
advanced2:00remaining
How to efficiently retrieve multiple items by keys using DocumentClient?
You need to get multiple items from the Users table by their
userId keys: '123', '456', and '789'. Which approach is the most efficient and correct using DocumentClient?Attempts:
2 left
💡 Hint
BatchGet allows retrieving multiple items by keys in one request.
✗ Incorrect
BatchGet is designed to retrieve multiple items by primary keys efficiently. Calling get multiple times is less efficient. Scan is expensive and not recommended for key lookups. Query does not support IN operator on partition key.
🔧 Debug
advanced2:00remaining
Why does this DocumentClient put operation fail with a ValidationException?
You try to put an item into the Users table with this code but get a ValidationException error. What is the cause?
DynamoDB
const params = {
TableName: 'Users',
Item: {
userId: 123,
name: 'Bob'
}
};
await docClient.put(params).promise();Attempts:
2 left
💡 Hint
Check the data type of the primary key value against the table schema.
✗ Incorrect
DynamoDB primary keys are strongly typed. If the table's primary key is a string, providing a number causes ValidationException. Item is correct property name. TableName is case sensitive but usually 'Users' is correct if created so. ConditionExpression is optional.
🧠 Conceptual
expert2:00remaining
What is a key benefit of using DynamoDB DocumentClient abstraction?
Why do developers prefer using the DynamoDB DocumentClient abstraction over the low-level DynamoDB client?
Attempts:
2 left
💡 Hint
Think about how DocumentClient handles data types compared to the low-level client.
✗ Incorrect
DocumentClient abstracts away the need to manually convert data to DynamoDB's attribute value format, making code simpler and easier to read. Transactions require explicit calls. Queries still require keys or indexes. Encryption is handled separately.