Reputation: 2298
I'm trying to get a list of entries from DynamoDb using FilterExpression. I'd like to return value if at least one of the statements are TRUE. But for some reason looks like AND is a default conditional operator and my result is empty. How to change default conditional operation to OR in NodeJS?
params = {
TableName: '......',
IndexName : 'user_id-index',
KeyConditionExpression: 'user_id = :user_id',
FilterExpression: 'contains (email, :key) OR contains (name, :key)',
ExpressionAttributeValues: {
":user_id": userId,
":key": item_to_search
}
};
Upvotes: 3
Views: 3731
Reputation: 10567
Your problem is that NAME
is a reserved word in DynamoDB. So, you'll have to use ExpressionAttributeNames
for that:
params = {
TableName: '......',
IndexName: "user_id-index",
KeyConditionExpression: "user_id = :user_id",
FilterExpression: "contains (email, :key) OR contains (#name, :key)",
ExpressionAttributeNames: {
"#name": "name"
}
ExpressionAttributeValues: {
":user_id": userId,
":key": item_to_search
}
};
Upvotes: 5