Complete the code to specify the return values when putting an item in DynamoDB.
response = table.put_item(Item=item, ReturnValues='[1]')
The ReturnValues parameter controls what is returned after a write operation. 'NONE' means no attributes are returned.
Complete the code to return the updated attributes after updating an item.
response = table.update_item(Key=key, UpdateExpression=expr, ReturnValues='[1]')
'UPDATED_NEW' returns only the attributes that were updated by the operation.
Fix the error in the code to return the entire item after a put operation.
response = table.put_item(Item=item, ReturnValues='[1]')
For put_item, the only valid ReturnValues are 'NONE' or 'ALL_OLD'. 'ALL_NEW' is invalid and causes an error.
Fill both blanks to return the old item attributes after deleting an item.
response = table.delete_item(Key=key, ReturnValues='[1]') old_item = response.get('[2]')
Setting ReturnValues to 'ALL_OLD' returns the deleted item's attributes under the 'Attributes' key in the response.
Fill all three blanks to update an item and get the entire new item back.
response = table.update_item(Key=key, UpdateExpression=expr, ReturnValues='[1]') new_item = response.get('[2]') print(new_item.get('[3]'))
ReturnValues='ALL_NEW' returns the entire updated item under 'Attributes'. Accessing 'Name' gets the updated attribute value.