Complete the code to define the primary key attribute name for a DynamoDB table.
KeySchema: [{ AttributeName: '[1]', KeyType: 'HASH' }]The primary key attribute name is usually a unique identifier like 'UserId' in single-table design.
Complete the code to add a sort key attribute name in the table schema.
KeySchema: [ { AttributeName: 'UserId', KeyType: 'HASH' }, { AttributeName: '[1]', KeyType: 'RANGE' } ]The sort key often represents a time or sequence attribute like 'Timestamp' to order items.
Fix the error in the DynamoDB query to fetch items by partition key.
Table.query({ KeyConditionExpression: 'UserId = :userId', ExpressionAttributeValues: { ':userId': [1] } })The value for ExpressionAttributeValues must be a string or number wrapped correctly. Here, the user ID should be a string in quotes.
Fill both blanks to create a DynamoDB item with partition key and sort key attributes.
Item: { 'UserId': [1], 'Timestamp': [2], 'Data': 'Sample' }The partition key 'UserId' is a string like 'user123', and the sort key 'Timestamp' is a string timestamp in ISO format.
Fill all three blanks to write a DynamoDB update expression that sets a new attribute and increments a counter.
UpdateExpression: 'SET [1] = :val, [2] = [3] + :inc', ExpressionAttributeValues: { ':val': 'active', ':inc': 1 }
'Status' is set to a new value, and 'Counter' is incremented by 1. The same attribute name 'Counter' is used twice in the update expression.