-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBatchWriteItem.js
More file actions
33 lines (33 loc) · 1.49 KB
/
Copy pathBatchWriteItem.js
File metadata and controls
33 lines (33 loc) · 1.49 KB
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
/* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#batchWriteItem-property */
/* ===================== BatchWriteItem ===================== */
var params = {
RequestItems: { // A map of TableName to Put or Delete requests for that table
table_name_1: [ // a list of Put or Delete requests for that table
{ // An example PutRequest
PutRequest: {
Item: { // a map of attribute name to AttributeValue
attribute_name: attribute_value,
// attribute_value (string | number | boolean | null | Binary | DynamoDBSet | Array | Object)
// ... more attributes ...
}
}
},
{ // An example DeleteRequest
DeleteRequest: {
Key: {
key_attribute_name: attribute_value, //(string | number | boolean | null | Binary)
// more primary attributes (if the primary key is hash/range schema)
}
}
},
// ... more put or delete requests ...
],
// ... more tables ...
},
ReturnConsumedCapacity: 'NONE', // optional (NONE | TOTAL | INDEXES)
ReturnItemCollectionMetrics: 'NONE', // optional (NONE | SIZE)
};
dynamodb.batchWriteItem(params, function(err, data) {
if (err) console.error(err); // an error occurred
else console.log(data); // successful response
});