Created
January 3, 2020 15:02
-
-
Save alex-samborskiy/08db67a5444ca0a38b71c8e958d1a2b2 to your computer and use it in GitHub Desktop.
[Mass operations DDB] #DynamoDB
This file contains hidden or 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"); | |
| AWS.config.update({ | |
| region : "us-west-2", | |
| endpoint : "http://localhost:8000" | |
| }); | |
| var documentclient = new AWS.DynamoDB.DocumentClient(); | |
| var itemsArray = []; | |
| var item1 = { | |
| DeleteRequest : { | |
| Key : { | |
| 'bag' : 'b1' | |
| } | |
| } | |
| }; | |
| itemsArray.push(item1); | |
| var item2 = { | |
| DeleteRequest : { | |
| Key : { | |
| 'bag' : 'b2' | |
| } | |
| } | |
| }; | |
| itemsArray.push(item2); | |
| var params = { | |
| RequestItems : { | |
| 'Bag' : itemsArray | |
| } | |
| }; | |
| documentclient.batchWrite(params, function(err, data) { | |
| if (err) { | |
| console.log('Batch delete unsuccessful ...'); | |
| console.log(err, err.stack); // an error occurred | |
| } else { | |
| console.log('Batch delete successful ...'); | |
| console.log(data); // successful response | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment