Created
October 13, 2019 12:06
-
-
Save girishramnani/312591657687c099ec1da6af1516d6f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type UserAction struct { | |
UserID string `dynamo:"ID,hash"` | |
Time time.Time `dynamo:",range"` | |
Seq int64 `dynamo:"Seq,range"` | |
UUID string | |
embeddedWithKeys | |
} | |
type embeddedWithKeys struct { | |
Embedded **[]byte `dynamo:"Embedded,hash"` | |
} | |
func main() { | |
create := &dynamodb.CreateTableInput{ | |
AttributeDefinitions: []*dynamodb.AttributeDefinition{ | |
{ | |
AttributeName: aws.String("ID"), | |
AttributeType: aws.String("S"), | |
}, | |
{ | |
AttributeName: aws.String("Time"), | |
AttributeType: aws.String("S"), | |
}, | |
{ | |
AttributeName: aws.String("Seq"), | |
AttributeType: aws.String("N"), | |
}, | |
{ | |
AttributeName: aws.String("Embedded"), | |
AttributeType: aws.String("B"), | |
}, | |
}, | |
GlobalSecondaryIndexes: []*dynamodb.GlobalSecondaryIndex{{ | |
IndexName: aws.String("Embedded-index"), | |
KeySchema: []*dynamodb.KeySchemaElement{{ | |
AttributeName: aws.String("Embedded"), | |
KeyType: aws.String("HASH"), | |
}}, | |
Projection: &dynamodb.Projection{ | |
ProjectionType: aws.String("ALL"), | |
}, | |
ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ | |
ReadCapacityUnits: aws.Int64(1), | |
WriteCapacityUnits: aws.Int64(2), | |
}, | |
}}, | |
KeySchema: []*dynamodb.KeySchemaElement{{ | |
AttributeName: aws.String("ID"), | |
KeyType: aws.String("HASH"), | |
}, { | |
AttributeName: aws.String("Time"), | |
KeyType: aws.String("RANGE"), | |
}}, | |
LocalSecondaryIndexes: []*dynamodb.LocalSecondaryIndex{{ | |
IndexName: aws.String("ID-Seq-index"), | |
KeySchema: []*dynamodb.KeySchemaElement{{ | |
AttributeName: aws.String("ID"), | |
KeyType: aws.String("HASH"), | |
}, { | |
AttributeName: aws.String("Seq"), | |
KeyType: aws.String("RANGE"), | |
}}, | |
Projection: &dynamodb.Projection{ | |
ProjectionType: aws.String("INCLUDE"), | |
NonKeyAttributes: []*string{aws.String("UUID")}, | |
}, | |
}}, | |
ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ | |
ReadCapacityUnits: aws.Int64(4), | |
WriteCapacityUnits: aws.Int64(2), | |
}, | |
Tags: []*dynamodb.Tag{ | |
&dynamodb.Tag{ | |
Key: aws.String("Tag-Key"), | |
Value: aws.String("Tag-Value"), | |
}, | |
}, | |
TableName: aws.String("UserActions"), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment