Gen*_*iaz 5 create-table amazon-web-services node.js amazon-dynamodb
我试图通过他们在nodejs上的aws-sdk在dynamodb上创建一个表.下面是我在dynamodb.createTable上传递的参数:
{
TableName: 'new_table',
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
KeySchema: [
{AttributeName: 'primary_key', KeyType: 'HASH'}
],
AttributeDefinitions: [
{AttributeName: 'primary_key', AttributeType: 'S'},
{AttributeName: 'some_attribute', AttributeType: 'S'}
]
}
Run Code Online (Sandbox Code Playgroud)
这回来了
ValidationException: One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions
Run Code Online (Sandbox Code Playgroud)
我通过在'KeySchema'上添加'some_attribute'来解决这个问题,但我想要的是一个没有'range'的'hash'表.
Gen*_*iaz 12
已解决:创建表时,只需指定KeySchema属性,而不是指定要放在表中的所有属性.所以在我的情况下,我只需要指定'primary_key'
{
TableName: 'new_table',
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
KeySchema: [
{AttributeName: 'primary_key', KeyType: 'HASH'}
],
AttributeDefinitions: [
{AttributeName: 'primary_key', AttributeType: 'S'},
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1756 次 |
| 最近记录: |