Need to scan Dynamo DB having records with list of dictionary objects. Below is my sample data
'toAddr': [{'type': 'email', 'address': 'aaa@gmail.com'}, {'type': 'email', 'address': 'bbb@gmail.com'}]}
Below lines of code would do the needful for me.
client = boto3.resource('dynamodb')
table = client.Table(table_name)
response = table.scan(FilterExpression="contains (#items, :itemVal)",
ExpressionAttributeNames={"#items": "toAddr"},
ExpressionAttributeValues={":itemVal":{"address":"aaa@gmail.com",
type":"email"}})
However i would like to build the filter Expression in below format
response = table.scan(FilterExpression=Attr('toAddr').contains('itemVal'),
ExpressionAttributeValues={":itemVal":{"address":"aaa@gmail.com",
"type":"email"}})
But this would result in an error
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Scan operation: Value provided in ExpressionAttributeValues unused in expressions: keys: {:itemVal}