में एक संरचना होने के लिए नोट: ये सभी डायनेमो डीबी के स्थानीय उदाहरण पर हो रहे हैं।त्रुटि अमान्य पैरामीटर टाइप: अपेक्षित पैराम्स। Iemem ['pid'] DynamoDB
var params = {
TableName: "TABLE-NAME",
KeySchema: [
{ AttributeName: "pid",
KeyType: "HASH"
}
],
AttributeDefinitions: [
{ AttributeName: "pid",
AttributeType: "S"
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
};
dynamodb.createTable(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
इस समारोह है कि डीबी में तत्वों (Node.js में) जोड़ने के लिए कहा जाता है किया जा रहा है:
इस कोड है कि मैं DynamoDB शैल से एक तालिका बनाने के लिए उपयोग किया है है:
function(request, response) {
params = {
TableName: 'TABLE-NAME',
Item: {
pid: 'abc123'
}
};
console.log(params);
dynamodb.putItem(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
}
उत्पादन है कि मैं मिलता है:
{ TableName: 'TABLE-NAME',
Item: { pid: 'abc123' } } // THIS IS PARAMS
{
"message": "There were 7 validation errors:\n* InvalidParameterType: Expected params.Item['pid'] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.Item['pid']\n* UnexpectedParameter: Unexpected key '1' found in params.Item['pid']\n* UnexpectedParameter: Unexpected key '2' found in params.Item['pid']\n* UnexpectedParameter: Unexpected key '3' found in params.Item['pid']\n* UnexpectedParameter: Unexpected key '4' found in params.Item['pid']\n* UnexpectedParameter: Unexpected key '5' found in params.Item['pid']",
"code": "MultipleValidationErrors",
"errors": [
{
"message": "Expected params.Item['pid'] to be a structure",
"code": "InvalidParameterType",
"time": "2015-11-26T15:51:33.932Z"
},
{
"message": "Unexpected key '0' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.933Z"
},
{
"message": "Unexpected key '1' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.933Z"
},
{
"message": "Unexpected key '2' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.933Z"
},
{
"message": "Unexpected key '3' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.933Z"
},
{
"message": "Unexpected key '4' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.934Z"
},
{
"message": "Unexpected key '5' found in params.Item['pid']",
"code": "UnexpectedParameter",
"time": "2015-11-26T15:51:33.934Z"
}
],
"time": "2015-11-26T15:51:33.944Z"
}
मुझे समझ नहीं आता क्यों या यह कैसे हो रही है कुंजी 0, 1, 2, 3, 4 और 5 जब वे पिछली पंक्ति में मुद्रित होने पर मौजूद नहीं हैं।
इसके अलावा, मैं Expected params.Item['pid'] to be a structure
त्रुटि को कैसे ठीक करूं? मैंने इसे एक स्ट्रिंग के रूप में घोषित कर दिया है और एक स्ट्रिंग स्टोर करने की कोशिश कर रहा हूं!
अन्य नोट्स: फ़ंक्शन में मैंने जो भी कोड उपयोग किया है, वह ठीक है जब मैं इसे खोल पर चलाता हूं। मैं भी एडब्ल्यूएस-sdk को शामिल किया है और कॉन्फ़िगर कर लेने के रूप में आवश्यक:
var AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';
AWS.config.endpoint = 'http://localhost:8000/'
var dynamodb = new AWS.DynamoDB();
'put' http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html पर प्रलेखित नहीं किया गया है और जब मैं इसका उपयोग करने का प्रयास करता हूं, तो मुझे एक त्रुटि मिलती है:" TypeError: dynamodb.put है एक समारोह नहीं "। – BlueMonkMN