Complete the code to remove an element from a set attribute using the DELETE expression.
UpdateExpression = "DELETE tags [1] :tagToRemove"
The DELETE keyword is used in DynamoDB UpdateExpression to remove elements from a set attribute.
Complete the code to define the value to remove from the set in ExpressionAttributeValues.
ExpressionAttributeValues = {":tagToRemove": [1]In DynamoDB, to remove an element from a set attribute, the value must be a set type. Using set(["tag1"]) correctly defines a set with one element.
Complete the UpdateExpression to correctly remove 'tag1' from the 'tags' set attribute.
UpdateExpression = "DELETE [1] :tagToRemove"
In DynamoDB UpdateExpression, the DELETE keyword is followed by the attribute name and the value placeholder separated only by a space. No operator like + or - is needed between them.
Fill both blanks to complete the UpdateExpression and ExpressionAttributeValues to remove 'tag2' from 'tags'.
UpdateExpression = "[1] tags :tagToRemove" ExpressionAttributeValues = {":tagToRemove": [2]
DELETE is the correct keyword to remove elements from a set. The value must be a set type, so set(["tag2"]) is correct.
Fill all three blanks to write a complete update call that removes 'tag3' from the 'tags' set attribute.
response = client.update_item(
TableName=[1],
Key=[2],
UpdateExpression="DELETE tags :tagToRemove",
ExpressionAttributeValues=[3]
)The TableName is a string with the table's name. The Key is a dictionary specifying the primary key. ExpressionAttributeValues uses the DynamoDB set type 'SS' to specify the string set containing 'tag3'.