AWS新手,尝试将数据放入表中。阅读完文档并尝试按照示例操作后,我遇到了此验证错误。
One of the required keys was not given a value
我的代码:
var conf = require("/directory");
var AccessKey = 'supersecretkey';
var SecretKey = 'supersecretkey';
var tableName = conf.tableCS;
var AWS = require('aws-sdk');
console.log("Endpoint: " + conf.endpoint);
AWS.config.update({
accessKeyId: AccessKey,
secretAccessKey: SecretKey,
region: conf.region,
endpoint: conf.endpoint
});
var docClient = new AWS.DynamoDB.DocumentClient();
var file = process.argv[2];
console.log("File: " + file);
var csv = require("fast-csv");
csv.fromPath(file)
.on("data", function(data) {
// Uncomment to see CSV data
// console.log(data);
var arrayLength = data.length;
for (var i = 0; i < arrayLength; i++) {
// console.log(data[i]);
var params = {
TableName: tableName,
Key: {
RefID: data
}
};
console.log("Adding a new item...");
docClient.put(params, function(err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
}
else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
// Looping through, now putItem into database
}
})
.on("end", function() {
console.log("done");
});
我找到了this,但我不理解range
关键部分。我在以下代码中创建了表,并且使用了hash
密钥,但没有range
密钥。这是我的问题吗?我会把范围键做什么?
var conf = require("/directory");
var AccessKey = 'supersecretkey';
var SecretKey = 'supersecretkey';
var tableName = conf.tableCSV;
// Take input from command line
process.argv.forEach(function(val, index, array) {
console.log(index + ': ' + val);
});
console.log("Table: " + tableName);
var AWS = require('aws-sdk');
console.log("Endpoint: " + conf.endpoint);
AWS.config.update({
accessKeyId: AccessKey,
secretAccessKey: SecretKey,
region: conf.region,
endpoint: conf.endpoint
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName: tableName,
KeySchema: [{
AttributeName: 'RefID',
KeyType: 'HASH'
}],
AttributeDefinitions: [{
AttributeName: 'RefID',
AttributeType: 'S'
}],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
};
dynamodb.createTable(params, function(err, table) {
if (err) {
console.log(err);
}
else {
console.log("TABLED CREATED");
console.log(table);
}
});
答案 0 :(得分:6)
在表定义中,您将键命名为if
,但在put操作中,您将命名键<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<!--<module name="com.fasterxml.jackson.core.jackson-core" slot="main" />-->
<!--<module name="com.fasterxml.jackson.core.jackson-annotations" slot="main" />-->
<module name="com.fasterxml.jackson.core.jackson-databind" slot="main" />
</exclusions>
</deployment>
</jboss-deployment-structure>
。如果您的表具有名为Ref-ID
的哈希键,则您插入的每个记录都需要Info
的值。