我是DynmaoDB的updateTable,我正在传递以下params对象:
{
"TableName": "movies",
"AttributeDefinitions": [{
"AttributeName": "subtitle",
"AttributeType": "S"
}],
"GlobalSecondaryIndexUpdates": [{
"Create": {
"IndexName": "subtitle",
"ProvisionedThroughput": {
"ReadCapacityUnits": "5",
"WriteCapacityUnits": "5"
},
"KeySchema": [{
"AttributeName": "subtitle",
"KeyType": "HASH"
}],
"Projection": {
"ProjectionType": "ALL"
}
}
}],
"ProvisionedThroughput": {
"ReadCapacityUnits": "5",
"WriteCapacityUnits": "5"
}
}
但是它给了我以下错误:
但基于documentation我需要通过它们?!那么为什么它会给我这个错误呢?
更新:
感谢Daniela Miao的建议,通过更改SDK版本解决了我的问题;但我遇到了另一个问题;再次基于documentation,如果我们想创建多个GSI,我们需要在“GlobalSecondaryIndexUpdates”字段中有多个对象,所以我传递了以下参数,但它没有更新GSI;但是,如果我只是创建一个GSI(在“GlobalSecondaryIndexUpdates”字段中传递一个对象,它可以工作);这是我为创建多个GSI而传递的参数:
{
"TableName": "movies",
"AttributeDefinitions": [{
"AttributeName": "id",
"AttributeType": "N"
}, {
"AttributeName": "title",
"AttributeType": "S"
}, {
"AttributeName": "subtitle",
"AttributeType": "S"
}],
"GlobalSecondaryIndexUpdates": [{
"Create": {
"IndexName": "title",
"ProvisionedThroughput": {
"ReadCapacityUnits": "5",
"WriteCapacityUnits": "5"
},
"KeySchema": [{
"AttributeName": "title",
"KeyType": "HASH"
}],
"Projection": {
"ProjectionType": "ALL"
}
}
}, {
"Create": {
"IndexName": "subtitle",
"ProvisionedThroughput": {
"ReadCapacityUnits": "5",
"WriteCapacityUnits": "5"
},
"KeySchema": [{
"AttributeName": "subtitle",
"KeyType": "HASH"
}],
"Projection": {
"ProjectionType": "ALL"
}
}
}]
}
我是否以错误的格式传递了参数?
谢谢: - )
答案 0 :(得分:1)
您使用的是哪个SDK版本?我认为为现有表添加索引是最近发布的新功能,因此只应在最新的SDK版本2.1.8中支持它:http://aws.amazon.com/releasenotes/SDK/JavaScript/3682546508553819