gpt4 book ai didi

node.js - 仅没有范围的Nodejs DynamoDB CreateTable哈希返回ValidationException

转载 作者:搜寻专家 更新时间:2023-10-31 22:37:21 26 4
gpt4 key购买 nike

我正在尝试在 dynamodb 上创建一个表通过他们的 aws-sdk on nodejs .下面是我传递给 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'}
]
}

返回

ValidationException: One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions

我已经通过在“KeySchema”上添加“some_attribute”来解决这个问题,但我想要的是一个没有“范围”的“哈希”表。

最佳答案

已解决:创建表时,只需要指定 KeySchema 属性,而不是要放在表上的所有属性。所以在我的例子中,我只需要指定'primary_key'

{
TableName: 'new_table',
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
},
KeySchema: [
{AttributeName: 'primary_key', KeyType: 'HASH'}
],
AttributeDefinitions: [
{AttributeName: 'primary_key', AttributeType: 'S'},
]
}

关于node.js - 仅没有范围的Nodejs DynamoDB CreateTable哈希返回ValidationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25698668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com