I created a "Movie" DynamoDB table from AWS DynamoDB tutorial posted at
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Js.01.html
with the attribute below:
var tableAttrs = {
TableName : "Movies",
KeySchema: [
{ AttributeName: "year", KeyType: "HASH"},
{ AttributeName: "title", KeyType: "RANGE" }
],
AttributeDefinitions: [
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
};
Now I want to use the batchGet command:
var params = {
"RequestItems" : {
"Movies": {
"Keys" : [
{year : { "N" : "1000" } },
{year : { "N" : "1001" } }
]
}
}
}
And running it with:
let db = new DynamoDB.DocumentClient({ apiVersion: '2012-08-10' })
let result = db.batchGet(params).promise();
But I am getting the error:
ValidationException: The provided key element does not match the schema
Why does the provided year as a key element does not match the schema? How to avoid this error and make it work?
Below is the screenshot showing the table keys:
