通过 updateTable 创建多个 GSI - DynamoDB [英] Creating multiple GSIs by updateTable - DynamoDB
问题描述
I'm uisng updateTable of DynmaoDB and based on the documentation, if we want to create multiple Global Secondary Indexes (GSIs) we need to have multiple objects in "GlobalSecondaryIndexUpdates" field, so I'm passing the following params, but it does not update the GSIs; however if I'm just creating one GSI (passing one object in "GlobalSecondaryIndexUpdates" field, it works); here is the params I'm passing for creating multiple GSIs:
{
"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"
}
}
}]
}
Am I passing the params in a wrong format?
From the DynamoDB documentation:
You can only create or delete one global secondary index per UpdateTable operation. However, if you run multiple UpdateTable operations simultaneously, you can create multiple indexes at a time. You can run up to five of these UpdateTable operations on a table at once, and each operation can create exactly one index.
这篇关于通过 updateTable 创建多个 GSI - DynamoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!