I am new to DynamoDB and am having trouble defining a table. I want to have a table like this:
item_name, create_date, update_date
and I need to query and update the items that have a specific item_name and update_date. So in boto3 I wrote
table.update_item(
Key={
'item_name': item_name,
'update_date': 0
},
UpdateExpression='SET update_date = :val1',
ExpressionAttributeValues={
':val1': 999999999
}
)
and I get botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: One or more parameter values were invalid: Cannot update attribute update_date. This attribute is part of the key.
In my table definition, I have item_name as hash key and update_date as range key. How am I going to fix the definition or code so that
- The update operation succeeds.
- I can quickly query the table on both
item_nameandupdate_dateattributes?