0
0
DynamoDBquery~10 mins

Return values on write in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the return values when putting an item in DynamoDB.

DynamoDB
response = table.put_item(Item=item, ReturnValues='[1]')
Drag options to blanks, or click blank then click option'
AALL_OLD
BUPDATED_NEW
CNONE
DALL_NEW
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ALL_NEW' when you want no return values causes unnecessary data to be returned.
Leaving ReturnValues empty defaults to 'NONE', but explicitly setting it is clearer.
2fill in blank
medium

Complete the code to return the updated attributes after updating an item.

DynamoDB
response = table.update_item(Key=key, UpdateExpression=expr, ReturnValues='[1]')
Drag options to blanks, or click blank then click option'
ANONE
BALL_NEW
CALL_OLD
DUPDATED_NEW
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NONE' returns no attributes, so you won't see the update results.
Confusing 'ALL_OLD' with 'UPDATED_NEW' returns old attributes before update.
3fill in blank
hard

Fix the error in the code to return the entire item after a put operation.

DynamoDB
response = table.put_item(Item=item, ReturnValues='[1]')
Drag options to blanks, or click blank then click option'
ANONE
BALL_OLD
CALL_NEW
DUPDATED_NEW
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ALL_NEW' with put_item causes a syntax error.
Expecting put_item to return the new item with 'ALL_NEW' is incorrect.
4fill in blank
hard

Fill both blanks to return the old item attributes after deleting an item.

DynamoDB
response = table.delete_item(Key=key, ReturnValues='[1]')
old_item = response.get('[2]')
Drag options to blanks, or click blank then click option'
AALL_OLD
BAttributes
CNONE
DItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NONE' returns no attributes, so old_item will be None.
Trying to access response['Item'] instead of response['Attributes'].
5fill in blank
hard

Fill all three blanks to update an item and get the entire new item back.

DynamoDB
response = table.update_item(Key=key, UpdateExpression=expr, ReturnValues='[1]')
new_item = response.get('[2]')
print(new_item.get('[3]'))
Drag options to blanks, or click blank then click option'
AALL_NEW
BAttributes
CName
DNONE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NONE' returns no attributes, so new_item will be None.
Trying to access a key not present in the updated attributes.