-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPutItem.js
25 lines (24 loc) · 1.16 KB
/
PutItem.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
/* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property */
/* ===================== PutItem ===================== */
var params = {
TableName: 'table_name',
Item: { // a map of attribute name to AttributeValue
attribute_name: attribute_value,
// attribute_value (string | number | boolean | null | Binary | DynamoDBSet | Array | Object)
// more attributes...
},
ConditionExpression: 'attribute_not_exists(attribute_name)', // optional String describing the constraint to be placed on an attribute
ExpressionAttributeNames: { // a map of substitutions for attribute names with special characters
//'#name': 'attribute name'
},
ExpressionAttributeValues: { // a map of substitutions for all attribute values
//':value': 'VALUE'
},
ReturnValues: 'NONE', // optional (NONE | ALL_OLD)
ReturnConsumedCapacity: 'NONE', // optional (NONE | TOTAL | INDEXES)
ReturnItemCollectionMetrics: 'NONE', // optional (NONE | SIZE)
};
dynamodb.putItem(params, function(err, data) {
if (err) console.error(err); // an error occurred
else console.log(data); // successful response
});