Skip to content

Instantly share code, notes, and snippets.

@PreSoichiSumi
Created June 9, 2017 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PreSoichiSumi/4f997a77abc664a8633289d537817aff to your computer and use it in GitHub Desktop.
Save PreSoichiSumi/4f997a77abc664a8633289d537817aff to your computer and use it in GitHub Desktop.
var AWS = require("aws-sdk");
//"http://localhost:8000"
AWS.config.update({
region: "us-west-1",
endpoint: "dynamodb.us-east-1.amazonaws.com"
});
var docClient = new AWS.DynamoDB.DocumentClient();
console.log("Querying for movies from 1985.");
var params = {
TableName : "Movies",
KeyConditionExpression: "#yr = :yyyy",
ExpressionAttributeNames:{
"#yr": "year"
},
ExpressionAttributeValues: {
":yyyy":1985
}
};
docClient.query(params, function(err, data) {
if (err) {
console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
} else {
console.log("Query succeeded.");
data.Items.forEach(function(item) {
console.log(" -", item.year + ": " + item.title);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment