I'm trying to do a Scan to my DynamoDB table in NodeJS, but I'm having trouble with ExpressionAttributeValues because don't recognize the placeholder I defined in the filter expression. I pass as paremeter an object with the information I want, but sends me this error:
"Unexpected Key ':Value' found in params.ExpressionAttributeValues['atributeValues'], "code":"Unexpected parameter"
I don't know what's happening because if I put the content of the object as parameter it works perfectly so I'm stucked.
function Consult(cb, Filter, Event){
var filterExpression = Filter+"= :Value";
if(typeof Event[Filter] == "string"){
//This is the object I'm trying to pass as parameter
var attributeValues = {
":Value" : {"S" : Event[Filter] }
}
}else {
//This is the object I'm trying to pass as parameter
var attributeValues = {
":Value" : {"N" : Event[Filter] }
}
}
dynamodb.scan({
TableName: tableName,
FilterExpression: filterExpression,
ExpressionAttributeValues:{ ":Value" : {"S" : Event[Filter] } } //This Works
ExpressionAttributeValues:{ attributeValues } //This don't and I don't know why
}, function(err, data){
if(err){
console.log(err);
cb(err, null);
} else {
cb(null, data.Items);
}
});
}