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 must be specified correctly to uniquely identify items. 'UserId' is a common choice for a partition key.
Complete the code to add a sort key attribute in the DynamoDB table schema.
KeySchema: [ { AttributeName: 'UserId', KeyType: 'HASH' }, { AttributeName: [1], KeyType: 'RANGE' } ]The sort key allows sorting and querying items with the same partition key. 'Timestamp' is commonly used to order events or records.
Fix the error in the query to fetch all items for a user using the partition key.
const params = { TableName: 'Users', KeyConditionExpression: 'UserId = [1]', ExpressionAttributeValues: { ':uid': userId } };In DynamoDB queries, placeholders for values start with a colon ':' and must match keys in ExpressionAttributeValues.
Fill both blanks to create a DynamoDB update expression that sets a new attribute and increments a counter.
UpdateExpression: 'SET [1] = :newVal, [2] = [2] + :inc'
The 'SET' clause updates 'LastLogin' to a new value and increments 'LoginCount' by a given amount.
Fill all three blanks to create a DynamoDB query that filters items by status and sorts by timestamp.
const params = { TableName: 'Orders', KeyConditionExpression: '[1] = :userId', FilterExpression: '[2] = :status', ScanIndexForward: [3] };The query uses 'UserId' as the partition key, filters by 'OrderStatus', and sorts results in descending order (ScanIndexForward: false).