Example 1
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyType RANGE -KeyDataType "S"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
AttributeDefinitions : {ForumName, Subject}
TableName : Thread
KeySchema : {ForumName, Subject}
TableStatus : CREATING
CreationDateTime : 10/28/2013 4:39:49 PM
ProvisionedThroughput : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes : 0
ItemCount : 0
LocalSecondaryIndexes : {}
This example creates a table named Thread that has a primary key consisting of 'ForumName' (key type hash) and 'Subject' (key type range). The schema used to construct the table can be piped into each cmdlet as shown or specified using the -Schema parameter.
Example 2
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S"
$schema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
AttributeDefinitions : {ForumName, LastPostDateTime, Subject}
TableName : Thread
KeySchema : {ForumName, Subject}
TableStatus : CREATING
CreationDateTime : 10/28/2013 4:39:49 PM
ProvisionedThroughput : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes : 0
ItemCount : 0
LocalSecondaryIndexes : {LastPostIndex}
This example creates a table named Thread that has a primary key consisting of 'ForumName' (key type hash) and 'Subject' (key type range). A local secondary index is also defined. The key of the local secondary index will be set automatically from the primary hash key on the table (ForumName). The schema used to construct the table can be piped into each cmdlet as shown or specified using the -Schema parameter.
Example 3
New-DDBTableSchema |
Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S" |
Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S" |
Add-DDBIndexSchema -IndexName "LastPostIndex" `
-RangeKeyName "LastPostDateTime" `
-RangeKeyDataType "S" `
-ProjectionType "keys_only" |
New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
AttributeDefinitions : {ForumName, LastPostDateTime, Subject}
TableName : Thread
KeySchema : {ForumName, Subject}
TableStatus : CREATING
CreationDateTime : 10/28/2013 4:39:49 PM
ProvisionedThroughput : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes : 0
ItemCount : 0
LocalSecondaryIndexes : {LastPostIndex}
This example shows how to use a single pipeline to create a table named Thread that has a primary key consisting of 'ForumName' (key type hash) and 'Subject' (key type range) and a local secondary index. The Add-DDBKeySchema and Add-DDBIndexSchema create a new TableSchema object for you if one is not supplied from the pipeline or the -Schema parameter.