-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateItem.js
29 lines (28 loc) · 1.43 KB
/
updateItem.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
var params = {
TableName: 'poppies',
Key: { // The primary key of the item (a map of attribute name to AttributeValue)
'date': { N: '1' }, //(string | number | boolean | null | Binary)
'time': { N: '1' }
},
UpdateExpression: 'SET #lastName = :newLastName, #firstName = :newFirstName', // String representation of the update to an attribute
// SET set-action , ...
// REMOVE remove-action , ... (for document support)
// ADD add-action , ...
// DELETE delete-action , ... (previous DELETE equivalent)
// ConditionExpression: '#lastName = :oldLastName AND #firstName = :oldFirstName', // optional String describing the constraint to be placed on an attribute
ExpressionAttributeNames: { // a map of substitutions for attribute names with special characters
'#lastName': 'lastName',
'#firstName': 'firstName',
},
ExpressionAttributeValues: { // a map of substitutions for all attribute values
':newLastName': { S: 'Pyle' },
':newFirstName': { S: 'Gomer' },
},
ReturnValues: 'UPDATED_NEW', // optional (NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW)
ReturnConsumedCapacity: 'INDEXES', // optional (NONE | TOTAL | INDEXES)
ReturnItemCollectionMetrics: 'SIZE', // optional (NONE | SIZE)
};
dynamodb.updateItem(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});