Created
June 9, 2017 09:04
-
-
Save PreSoichiSumi/4f997a77abc664a8633289d537817aff to your computer and use it in GitHub Desktop.
This file contains 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
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