Complete the code to specify the partition key in the DynamoDB query.
KeyConditionExpression = Key('[1]').eq('User123')
The partition key for this table is UserId. It is used to filter items belonging to a specific user.
Complete the code to add a filter expression that restricts access to items with status 'active'.
FilterExpression = Attr('status').[1]('active')
The eq method checks if the attribute equals the given value, here 'active'.
Fix the error in the condition expression to check if the attribute 'role' is 'admin'.
KeyConditionExpression = Key('UserId').eq('User123') & Key('[1]').eq('admin')
The attribute name is case-sensitive and exactly 'role'. Using 'role' ensures the condition checks the correct attribute.
Fill in the blanks to create a filter expression that allows only items where 'department' is 'sales' and 'accessLevel' is greater than 3.
FilterExpression = Attr('[1]').eq('sales') & Attr('[2]').[3](3)
The filter checks that department equals 'sales' and accessLevel is greater than 3 using gt.
Fill in the blanks to build a filter expression that filters items where 'UserId' equals 'User123', 'status' is 'active', and 'lastLogin' is after 2023-01-01.
FilterExpression = Attr('[1]').eq('User123') & Attr('[2]').eq('active') & Attr('[3]').[4]('2023-01-01')
This expression filters items where UserId equals 'User123', status equals 'active', and lastLogin is greater than the date '2023-01-01'.