Complete the code to specify the primary key attribute name in a DynamoDB table creation.
KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }]The primary key attribute name is usually a unique identifier like 'UserId'.
Complete the code to define a Global Secondary Index (GSI) partition key.
GlobalSecondaryIndexes: [{ IndexName: 'StatusIndex', KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }] }]The GSI partition key is often an attribute like 'Status' to query items by their status.
Fix the error in the query to get an item by primary key.
const params = { TableName: 'Users', Key: { [1]: '12345' } };The Key must use the primary key attribute name, which is 'UserId' here.
Fill both blanks to create a query using a GSI to find items by status and sort by timestamp.
const params = { TableName: 'Orders', IndexName: 'StatusIndex', KeyConditionExpression: '[1] = :statusVal AND [2] > :timeVal', ExpressionAttributeValues: { ':statusVal': 'shipped', ':timeVal': 1609459200 } };The query uses 'Status' as the partition key and 'Timestamp' as the sort key in the GSI.
Fill all three blanks to create a DynamoDB update expression that sets a new status and increments a counter.
const params = { TableName: 'Tasks', Key: { TaskId: 'task123' }, UpdateExpression: 'SET [1] = :newStatus, [2] = [3] + :inc', ExpressionAttributeValues: { ':newStatus': 'completed', ':inc': 1 } };The update expression sets the 'Status' attribute and increments the 'Count' attribute by 1.