0
0
DynamoDBquery~20 mins

Return values on write in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Return Values Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What does ReturnValues: "ALL_OLD" return on a PutItem?
You perform a PutItem operation with ReturnValues set to "ALL_OLD". What will the response contain if the item did not exist before?
DynamoDB
PutItem({ TableName: "Users", Item: { UserId: "123", Name: "Alice" }, ReturnValues: "ALL_OLD" })
AThe primary key attributes only
BAn empty object because no previous item existed
CAn error because <code>ALL_OLD</code> is invalid for <code>PutItem</code>
DThe newly inserted item attributes
Attempts:
2 left
💡 Hint
Think about what ALL_OLD means when no item was replaced.
query_result
intermediate
2:00remaining
What does ReturnValues: "UPDATED_NEW" return on an UpdateItem?
You run an UpdateItem with ReturnValues set to "UPDATED_NEW". What will the response contain?
DynamoDB
UpdateItem({ TableName: "Products", Key: { Id: "p1" }, UpdateExpression: "SET Price = :p", ExpressionAttributeValues: { ":p": 20 }, ReturnValues: "UPDATED_NEW" })
AAll attributes of the item after the update
BAll attributes of the item before the update
COnly the attributes that were updated with their new values
DNo attributes, just a success status
Attempts:
2 left
💡 Hint
Focus on what UPDATED_NEW means in the context of updated attributes.
📝 Syntax
advanced
2:00remaining
Which ReturnValues option is invalid for DeleteItem?
Select the ReturnValues option that will cause a syntax or runtime error when used with DeleteItem.
DynamoDB
DeleteItem({ TableName: "Orders", Key: { OrderId: "o123" }, ReturnValues: ? })
A"ALL_OLD"
B"ALL_NEW"
C"NONE"
D"UPDATED_NEW"
Attempts:
2 left
💡 Hint
Consider which return values make sense for a delete operation.
🧠 Conceptual
advanced
2:00remaining
Why use ReturnValues: "ALL_NEW" in UpdateItem?
What is the main reason to set ReturnValues to "ALL_NEW" when updating an item?
ATo get the entire item as it looks after the update
BTo get only the attributes that were updated
CTo get the item as it was before the update
DTo prevent the update from happening if the item exists
Attempts:
2 left
💡 Hint
Think about when you want to see the full updated item.
🔧 Debug
expert
3:00remaining
Why does this UpdateItem with ReturnValues: "ALL_OLD" return empty?
You run this UpdateItem on a non-existing item with ReturnValues set to "ALL_OLD". Why is the returned attribute map empty?
DynamoDB
UpdateItem({ TableName: "Inventory", Key: { ItemId: "i999" }, UpdateExpression: "SET Stock = :s", ExpressionAttributeValues: { ":s": 10 }, ReturnValues: "ALL_OLD" })
ABecause the item did not exist before, so no old attributes to return
BBecause <code>ALL_OLD</code> only returns updated attributes, and none were updated
CBecause <code>ReturnValues</code> is ignored on <code>UpdateItem</code>
DBecause the update failed silently without error
Attempts:
2 left
💡 Hint
Consider what ALL_OLD means when the item is new.