Мне нужно получить несколько элементов из Dynamodb, используя лямбду с node.js.Я использую метод batchGet AWS.DynamoDB.DocumentClient ().Я получаю ошибку ниже.
{
"errorMessage": "The provided key element does not match the schema",
"errorType": "ValidationException",
"stackTrace": [
"Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)",
"Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
"Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)"
]
}
Ниже приведен мой код.
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();
const params = {
RequestItems: {
"usersTable_Test": {
Keys: [{
userId: '123'}
],
ProjectionExpression: "userId"
}
}
};
const res = await docClient.batchGet(params).promise();
Я также пробовал метод batchGetItem, но затем получаю ошибку ниже.
{
"errorMessage": "docClient.batchGetItem is not a function",
"errorType": "TypeError",
"stackTrace": [
"exports.handler (/var/task/index.js:62:30)",
"<anonymous>",
"process._tickDomainCallback (internal/process/next_tick.js:228:7)"
]
}