I have dynamoDB table,
Table name xx
Primary partition key id (Number)
Primary sort key name (String)
And I want to query it by name.
'use strict';
const AWS = require("aws-sdk");
const dynamodb = new AWS.DynamoDB();
const docClient = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, ctx, callback) {
var params = {
TableName: 'xx',
KeyConditionExpression: "#name = :name",
ExpressionAttributeNames:{
"#name": "name"
},
ExpressionAttributeValues: {
":name":event.name
}
};
docClient.query(params, function(err, data){
if(err){
callback(err, null);
}else{
callback(null, data);
}
});
}
but I got an error called :"Query condition missed key schema element:id:" how to deal with that?