Skip to content

Instantly share code, notes, and snippets.

@alex-samborskiy
Created January 3, 2020 15:02
Show Gist options
  • Select an option

  • Save alex-samborskiy/08db67a5444ca0a38b71c8e958d1a2b2 to your computer and use it in GitHub Desktop.

Select an option

Save alex-samborskiy/08db67a5444ca0a38b71c8e958d1a2b2 to your computer and use it in GitHub Desktop.
[Mass operations DDB] #DynamoDB
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