I'm currently having trouble querying a DynamoDB table where the partition key, id, is of type number. This is for a wider project for my own Alexa Skill on AWS. My skill will take as input from the user, a unique id value, which is of slot type AMAZON.NUMBER.
I've looked at the documentation for query and nothing I've tried worked so I decided to start from scratch to a template.
Again, I am just trying to query a table for data based on a partition key called "id" that has a numeric value. The Code below is what I have managed to narrow down as the source of the error.
var params = {
TableName : "QueryTestTable",
KeyConditionExpression: "#pkey = :value",
ExpressionAttributeNames:{
"#pkey": "id"
},
ExpressionAttributeValues: {
":value": idNumber
}
};
return docClient.query(params, function(err,data) {
if (err) {
console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
} else {
console.log("Query succeeded.");
console.log("data = " + JSON.stringify(data,null,2));
data.Items.forEach(function(item) {
console.log(" -", item.id + ": " + item.firstName);
results += item.id + " has name " +item.firstName + " " + item.lastName + ".\n";
});
}
if (results)
speakOutput = results;
else
speakOutput = "Sorry, no result for " + idNumber +" was found in the database.";
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt()
.withSimpleCard(SKILL_NAME, speakOutput) //added to generate video output.
.getResponse();
})
I'm just using a simplified version of my table for now. But the above code snippet. For some reason, It keeps skipping to the no entries found in the database statement.