'Can't figure out the correct payload to BatchGetItemCommand in aws-sdk 3
I can't figure out what the payload should be for BatchGetItemCommand. I've read the docs (https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-example-table-read-write-batch.html) and looked at the Typescript typings.
This is the table:
StagesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-${opt:stage}-StagesTable
AttributeDefinitions:
- AttributeName: color
AttributeType: S
- AttributeName: stage
AttributeType: S
KeySchema:
- AttributeName: color
KeyType: HASH
- AttributeName: stage
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
I am trying to retrieve the two rows where the color is blue or green. This is my payload
const payload = {
RequestItems: {
tableName: {
Keys: [
{
color: { S: 'blue' },
},
{
color: { S: 'green' },
},
],
}
}
};
I get
(node:79852) UnhandledPromiseRejectionWarning: ValidationException: The provided key element does not match the schema at deserializeAws_json1_0BatchGetItemCommandError (.../node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:589:24) at processTicksAndRejections (internal/process/task_queues.js:95:5)
What am I doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
