forked from Werneror/Practise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoviesItemOps03.js
36 lines (31 loc) · 887 Bytes
/
MoviesItemOps03.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var AWS = require("aws-sdk");
AWS.config.update({
region: "us-west-2",
endpoint: "http://localhost:8000"
});
var docClient = new AWS.DynamoDB.DocumentClient();
var table = "Movies";
var year = 2015;
var title = "The Big New Movie";
var params = {
TableName: table,
Key:{
"year": year,
"title": title
},
UpdateExpression: "set info.rating = :r, info.plot=:p, info.actors=:a",
ExpressionAttributeValues:{
":r": 5.5,
":p": "Everything happens all at once.",
":a": ["Larry", "Moe", "Curly"]
},
ReturnValues: "UPDATED_NEW"
};
console.log("Updating the item...");
docClient.update(params, function(err, data){
if(err){
console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
}else{
console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
}
});