我对 DynamoDB 中的某些东西感到非常困惑:
对于表中的任何项目,如果项目中存在索引排序键值,DynamoDB 只会写入相应的索引条目。如果排序键没有出现在每个表项中,则称该索引为稀疏索引。
[...]
要跟踪未结订单,您可以在 CustomerId(分区键)和 IsOpen(排序键)上创建索引。只有表中定义了 IsOpen 的订单才会出现在索引中。
但是,如果您使用备用排序键定义了 LSI,则在创建新项目时,备用排序键永远不能为空。因此,索引根本不是稀疏的,因为我创建的每个项目都会在索引中结束。
我错过了什么?
AWS的新增功能,试图将数据放入表中。阅读文档并尝试按照示例操作后,我遇到了此验证错误。
One of the required keys was not given a value
Run Code Online (Sandbox Code Playgroud)
我的代码:
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 …Run Code Online (Sandbox Code Playgroud)