Created
February 20, 2018 23:49
-
-
Save israelb/771a45617331b82e6b23da0f60d07ec8 to your computer and use it in GitHub Desktop.
dynamo localmente
This file contains hidden or 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
// create table | |
var params = { | |
TableName: 'Report', | |
KeySchema: [ | |
{ | |
AttributeName: 'UserID', | |
KeyType: 'HASH', | |
}, | |
], | |
AttributeDefinitions: [ | |
{ | |
AttributeName: 'UserID', | |
AttributeType: 'S', | |
}, | |
], | |
ProvisionedThroughput: { | |
ReadCapacityUnits: 5, | |
WriteCapacityUnits: 5, | |
}, | |
}; | |
dynamodb.createTable(params, function(err, data) { | |
if (err) ppJson(err); // an error occurred | |
else ppJson(data); // successful response | |
}); | |
This file contains hidden or 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
// list items | |
var dynamodb = new AWS.DynamoDB({ | |
region: 'us-east-1', | |
endpoint: "http://localhost:8000" | |
}); | |
var tableName = "Report"; | |
var params = { | |
TableName: tableName, | |
Select: "ALL_ATTRIBUTES" | |
}; | |
function doScan(response) { | |
if (response.error) ppJson(response.error); // an error occurred | |
else { | |
ppJson(response.data); // successful response | |
// More data. Keep calling scan. | |
if ('LastEvaluatedKey' in response.data) { | |
response.request.params.ExclusiveStartKey = response.data.LastEvaluatedKey; | |
dynamodb.scan(response.request.params) | |
.on('complete', doScan) | |
.send(); | |
} | |
} | |
} | |
console.log("Starting a Scan of the table"); | |
dynamodb.scan(params) | |
.on('complete', doScan) | |
.send(); |
This file contains hidden or 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
# server | |
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment