Skip to content

Commit

Permalink
GSI1 for Dynamodb
Browse files Browse the repository at this point in the history
  • Loading branch information
unamashana committed Nov 16, 2023
1 parent 04d24e1 commit 1b88cc7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ddb/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (a *Admin) CreateTable(tableName string) error {
AttributeDefinitions: []types.AttributeDefinition{
{AttributeName: aws.String("PK"), AttributeType: types.ScalarAttributeTypeS},
{AttributeName: aws.String("SK"), AttributeType: types.ScalarAttributeTypeS},
{AttributeName: aws.String("GSI1PK"), AttributeType: types.ScalarAttributeTypeS},
{AttributeName: aws.String("GSI1SK"), AttributeType: types.ScalarAttributeTypeS},
},
KeySchema: []types.KeySchemaElement{
{
Expand All @@ -36,6 +38,26 @@ func (a *Admin) CreateTable(tableName string) error {
KeyType: types.KeyTypeRange,
},
},
GlobalSecondaryIndexes: []types.GlobalSecondaryIndex{{
IndexName: aws.String("GSI1"),
KeySchema: []types.KeySchemaElement{
{
AttributeName: aws.String("GSI1PK"),
KeyType: types.KeyTypeHash,
},
{
AttributeName: aws.String("GSI1SK"),
KeyType: types.KeyTypeRange,
},
},
Projection: &types.Projection{
ProjectionType: types.ProjectionTypeAll,
},
ProvisionedThroughput: &types.ProvisionedThroughput{
ReadCapacityUnits: aws.Int64(1),
WriteCapacityUnits: aws.Int64(1),
},
}},
ProvisionedThroughput: &types.ProvisionedThroughput{
ReadCapacityUnits: aws.Int64(1),
WriteCapacityUnits: aws.Int64(1),
Expand Down

0 comments on commit 1b88cc7

Please sign in to comment.