Проблема:
Я борюсь с инструкцией updateItem
в DynamoDB AWS.Насколько я могу судить, я написал код точно так, как показано в документации и по указанию службы поддержки Amazon.Тем не менее, я получаю сообщение об ошибке с 13 ошибками проверки.Они не имеют смысла для меня.
Что я уже сделал:
Я искал StackOverflow и читал несколько вопросов AWS DynamoDB.Никто не был на точке.Я искал в Интернете в целом и не нашел помощи.Я читал справочный материал AWS DynamoDB, но он плотный и идет медленно.Я все еще работаю над этим.
Я создал этот кодовый штифт minCase pin .
Любая помощь будет оценена в крайнем случае.
Код JavaScript
var dynamoDB = new AWS.DynamoDB();
params0 = {
'TableName': 'FHCRoomCounts',
'Key': {
timeSlot: '0830',
room: 'chapel',
},
'UpdateExpression': 'ADD registrants :n',
'ExpressionAttributeValues': {
':n' : 1,
},
'ReturnValues': 'ALL_NEW'
};
console.log('log params0 : ');
for(let [key, value] of Object.entries(params0)) {
console.log(key, value);
} // end for-let
console.log('calling dynamoDB.updateItem');
dynamoDB.updateItem(params0, function(err, data) {
if (err) {
console.log('Unable to update registrant: ' + '\n' + JSON.stringify(err, undefined, 2));
} else {
console.log('Increase registrant succeeded: ' + '\n' + JSON.stringify(data, undefined, 2));
} // end else
Сообщение об ошибке: 13 ошибок валидации.
Ниже приведен журнал консоли.Я зарегистрировал объект params, чтобы вы могли видеть, что отправляется в AWS.
jquery loaded
AWS sdk loaded
log params0 :
TableName FHCRoomCounts
Key Object { timeSlot: "0830", room: "chapel" }
UpdateExpression ADD registrants :n
ExpressionAttributeValues Object { ":n": 1 }
ReturnValues ALL_NEW
calling dynamoDB.updateItem
Unable to update registrant:
{
"message": "There were 13 validation errors:\n*
InvalidParameterType: Expected params.Key['timeSlot'] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '1' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '2' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '3' found in params.Key['timeSlot']\n* InvalidParameterType: Expected params.Key['room'] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '1' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '2' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '3' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '4' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '5' found in params.Key['room']\n* InvalidParameterType: Expected params.ExpressionAttributeValues[':n'] to be a structure",
"code": "MultipleValidationErrors",
"errors": [
{
"message": "Expected params.Key['timeSlot'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.288Z"
},
{
"message": "Unexpected key '0' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '1' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '2' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '3' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Expected params.Key['room'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '0' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '1' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '2' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '3' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '4' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '5' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Expected params.ExpressionAttributeValues[':n'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.291Z"
}
],
"time": "2019-06-15T04:51:05.291Z",
"stack": "validate@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:61:19246\n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25947\ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26769\ns@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26635\n[311]</a.EventListeners.Core</</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25280\nt@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25669\ngetCredentials/</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25990\nget@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:30534\ngetCredentials/<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25896\ngetCredentials@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25997\n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25149\ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26740\nemit@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26480\nemitEvent@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:12277\ne@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:7919\n[363]</i.prototype.runTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:64:9533\nrunTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9575\nsend@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9468\nmakeRequest@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:30482\ndefineMethods/</e.prototype[t]@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:63:5136\nupdateTable@https://steve-alexander-pfmi.squarespace.com/test-register-2019:110:12\n"
}