Reputation: 11690
I have created DynamoDB
table:
[
'AttributeDefinitions' => [
[
'AttributeName' => 'UserId',
'AttributeType' => 'N',
],
[
'AttributeName' => 'Created',
'AttributeType' => 'S',
],
],
'KeySchema' => [
[
'AttributeName' => 'UserId',
'KeyType' => 'HASH',
],
[
'AttributeName' => 'Created',
'KeyType' => 'RANGE',
],
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5,
],
'TableName' => 'Images',
]
Adding a data, TargetUserIdUserId
field is added as well. How do I set GSI for three columns (UserId, TragetUserId, Created)? Or maybe I need to modify table KeySchema
?
Looks like I cannot do it using AWS Console (only two keys are available):
Upvotes: 0
Views: 180
Reputation: 14799
A DynamoDB key can be made of one attribute (partition key) or two attributes (partition key and range key).
You should create a new attribute which combines UserId + TargetUserIdUserId and make this the GSI partition key, then make Created the range key.
Upvotes: 1