Я пытаюсь создать простую таблицу с использованием оболочки javascript DynamoDB, и я получаю это исключение:
{
"message": "The number of attributes in key schema must match the number of attributes defined in attribute definitions.",
"code": "ValidationException",
"time": "2015-06-16T10:24:23.319Z",
"statusCode": 400,
"retryable": false
}
Ниже приведена таблица Im, пытающаяся создать:
var params = {
TableName: 'table_name',
KeySchema: [
{
AttributeName: 'hash_key_attribute_name',
KeyType: 'HASH',
},
],
AttributeDefinitions: [
{
AttributeName: 'hash_key_attribute_name',
AttributeType: 'S',
},
{
AttributeName: 'attribute_name_1',
AttributeType: 'S',
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
};
dynamodb.createTable(params, function(err, data) {
if (err) print(err);
else print(data);
});
Однако, если я добавлю второй атрибут в keySchema, он отлично работает. Ниже рабочего стола:
var params = {
TableName: 'table_name',
KeySchema: [
{
AttributeName: 'hash_key_attribute_name',
KeyType: 'HASH',
},
{
AttributeName: 'attribute_name_1',
KeyType: 'RANGE',
}
],
AttributeDefinitions: [
{
AttributeName: 'hash_key_attribute_name',
AttributeType: 'S',
},
{
AttributeName: 'attribute_name_1',
AttributeType: 'S',
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
};
dynamodb.createTable(params, function(err, data) {
if (err) print(err);
else print(data);
});
Я не хочу добавлять диапазон к ключевой схеме. Любая идея, как это исправить?