majindageta
10/1/2019 - 2:01 PM

DynamoDB local

cd dynamoLocalDirectory
# run the java command
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

#don't close this terminal, open another window
#create the table using a json file
aws dynamodb create-table 
  --cli-input-json file:///Users/davidericci/Projects/meteosuper-api/localDynamo/create-forecastTable.json 
  --endpoint-url http://localhost:8000
  
#delete table 
aws dynamodb delete-table --table-name meteosuper-forecasts-dev --endpoint-url http://localhost:8000

#scan table
aws dynamodb scan --table-name meteosuper-forecasts-dev --endpoint-url http://localhost:8000

#list tables
aws dynamodb list-tables --endpoint-url http://localhost:8000

#query
aws dynamodb query --table-name meteosuper-forecasts-dev 
                   --endpoint-url http://localhost:8000 
                   --key-condition-expression "PK = :pk" 
                   --expression-attribute-values  '{":pk":{"S":"3400737"}}'
                   #this is an example
{
    "AttributeDefinitions": [
        {
            "AttributeName": "PK",
            "AttributeType": "S"
        },
        {
            "AttributeName": "SK",
            "AttributeType": "S"
        }
    ],
    "KeySchema": [
        {
            "AttributeName": "PK",
            "KeyType": "HASH"
        },
        {
            "AttributeName": "SK",
            "KeyType": "RANGE"
        }
    ],
    "ProvisionedThroughput": {
        "ReadCapacityUnits": 25,
        "WriteCapacityUnits": 25
    },
    "TableName": "meteosuper-locations-dev"
}