I am trying to get items out of a DynamoDB table using the Node JS AWS-SDK. The function getItem
is working fine but BatchGetItem
is harder to use.
I use the official documentation: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/Client.html#batchGetItem-property
I am looking for examples on how to use this function correctly, but I can't find any. The code I wrote is:
var params = {
"RequestItems" : {
"Keys" : [
{"HashKeyElement" : { "N" : "1000" } },
{"HashKeyElement" : { "N" : "1001" } }
]
}
}
db.client.batchGetItem(params, function(err, data) {
console.log('error: '+ err);
console.log(jsDump.parse(data));
});
I get a SerializationException: Start of list found where not expected
error but as far as my NodeJS and JSON expertise goes, my syntax is correct. But it's confusing:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/API_BatchGetItems.html
In that syntax example, you have to provide the table name.