diff --git a/DynamoDB/expression-attribute-names.json b/DynamoDB/expression-attribute-names.json new file mode 100644 index 0000000..e69de29 diff --git a/DynamoDB/expression-attribute-values.json b/DynamoDB/expression-attribute-values.json new file mode 100644 index 0000000..e69de29 diff --git a/DynamoDB/item.json b/DynamoDB/item.json new file mode 100644 index 0000000..eb9b062 --- /dev/null +++ b/DynamoDB/item.json @@ -0,0 +1,8 @@ +{ + "Name": { "S": "USS Okinawa" }, + "Registry": { "S": "NCC-13958" }, + "ShipClass": { "S": "Excelsior" }, + "Description": { + "S": "Ship commanded by Admiral James Leyton and on which Benjamin Sisko served as first officer." + } +} diff --git a/DynamoDB/key.json b/DynamoDB/key.json new file mode 100644 index 0000000..8620017 --- /dev/null +++ b/DynamoDB/key.json @@ -0,0 +1,4 @@ +{ + "Registry": { "S": "NCC-13958" }, + "ShipClass": { "S": "Excelsior" } +} diff --git a/DynamoDB/request-items.json b/DynamoDB/request-items.json new file mode 100644 index 0000000..20e3665 --- /dev/null +++ b/DynamoDB/request-items.json @@ -0,0 +1,14 @@ +{ + "Starships": { + "Keys": [ + { + "Registry": { "S": "NCC-13958" }, + "ShipClass": { "S": "Excelsior" } + }, + { + "Registry": { "S": "NCC-1864" }, + "ShipClass": { "S": "Miranda" } + } + ] + } +} diff --git a/DynamoDB/scratchpad.txt b/DynamoDB/scratchpad.txt new file mode 100644 index 0000000..95911ae --- /dev/null +++ b/DynamoDB/scratchpad.txt @@ -0,0 +1,69 @@ +## Create DynamoDB Table +aws dynamodb create-table \ + --table-name Starships \ + --attribute-definitions \ + AttributeName=ShipClass,AttributeType=S \ + AttributeName=Registry,AttributeType=S \ + --key-schema \ + AttributeName=ShipClass,KeyType=HASH \ + AttributeName=Registry,KeyType=RANGE \ + --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \ + --region us-east-1 + +## Describe the table +aws dynamodb describe-table --table-name Starships --output table + +## Batch-Write-Item +aws dynamodb batch-write-item --request-items file://batches/batch-000.json +aws dynamodb batch-write-item --request-items file://batches/batch-001.json +aws dynamodb batch-write-item --request-items file://batches/batch-002.json +aws dynamodb batch-write-item --request-items file://batches/batch-003.json +aws dynamodb batch-write-item --request-items file://batches/batch-004.json +aws dynamodb batch-write-item --request-items file://batches/batch-005.json +aws dynamodb batch-write-item --request-items file://batches/batch-006.json +aws dynamodb batch-write-item --request-items file://batches/batch-007.json +aws dynamodb batch-write-item --request-items file://batches/batch-008.json +aws dynamodb batch-write-item --request-items file://batches/batch-009.json +aws dynamodb batch-write-item --request-items file://batches/batch-010.json +aws dynamodb batch-write-item --request-items file://batches/batch-011.json +aws dynamodb batch-write-item --request-items file://batches/batch-012.json + +## Get-Item +aws dynamodb get-item --table-name Starships --key file://key.json + +## Batch-Get-Item +aws dynamodb batch-get-item --request-items file://request-items.json + +## Delete-Item +aws dynamodb delete-item --table-name Starships --key file://key.json + +## Put-Item +aws dynamodb put-item --table-name Starships --item file://item.json + +## Update-Item +aws dynamodb update-item \ + --table-name Starships \ + --key file://key.json \ + --update-expression "Set #D = :D" \ + --expression-attribute-names file://expression-attribute-names.json \ + --expression-attribute-values file://expression-attribute-values.json \ + --return-values ALL_NEW + +## Scan +aws dynamodb scan \ + --table-name Starships \ + --filter-expression "begins_with(Description, :D)" \ + --expression-attribute-values '{":D": {"S": "Destroyed"}}' + +## Query +aws dynamodb query \ + --table-name Starships \ + --key-condition-expression "ShipClass = :C" \ + --expression-attribute-values '{":C": {"S": "Galaxy"}}' + +## Transact +aws dynamodb transact-get-items \ + --transact-items file://transact-get-items.json + +aws dynamodb transact-write-items \ + --transact-items file://transact-write-items.json \ No newline at end of file diff --git a/DynamoDB/transact-get-items.json b/DynamoDB/transact-get-items.json new file mode 100644 index 0000000..b6f932c --- /dev/null +++ b/DynamoDB/transact-get-items.json @@ -0,0 +1,20 @@ +[ + { + "Get": { + "Key": { + "Artist": { "S": "Acme Band" }, + "SongTitle": { "S": "Happy Day" } + }, + "TableName": "MusicCollection" + } + }, + { + "Get": { + "Key": { + "Artist": { "S": "No One You Know" }, + "SongTitle": { "S": "Call Me Today" } + }, + "TableName": "MusicCollection" + } + } +] diff --git a/DynamoDB/transact-write-items.json b/DynamoDB/transact-write-items.json new file mode 100644 index 0000000..4f73d1a --- /dev/null +++ b/DynamoDB/transact-write-items.json @@ -0,0 +1,26 @@ +[ + { + "Update": { + "Key": { + "Artist": { "S": "Acme Band" }, + "SongTitle": { "S": "Happy Day" } + }, + "UpdateExpression": "SET AlbumTitle = :newval", + "ExpressionAttributeValues": { + ":newval": { "S": "Updated Album Title" } + }, + "TableName": "MusicCollection", + "ConditionExpression": "attribute_not_exists(Rating)" + } + }, + { + "Delete": { + "Key": { + "Artist": { "S": "No One You Know" }, + "SongTitle": { "S": "Call Me Today" } + }, + "TableName": "MusicCollection", + "ConditionExpression": "attribute_not_exists(Rating)" + } + } +]