I use DynamoDB DocumentClient to delete the item on multiple tables using Class: AWS.DynamoDB.DocumentClient
The issue is, when I tried to delete multiple tables use promised.all()
, it run didn't delete the item but didn't return any exception from AWS. I'm thinking is because I didn't return the promise?
Other thing is, on the DynamoDB page, it mentioned write capacity as:
One write capacity unit represents one write per second for items up to 1 KB in size. If you need to write an item that is larger than 1 KB, DynamoDB will need to consume additional write capacity units. The total number of write capacity units required depends on the item size.
If each of my item is 0.4KB, I want to delete 1000 items, it will be 400 KB, then I should set the write capacity unit as 400 or 1000? (if I didn't delay the request at all).
return Promise.all([deleteItemOnTable(table1), deleteItemOnTable(table2)]);
var documentClient = new AWS.DynamoDB.DocumentClient();
function deleteItemOnTable(tablePramas, dataToBeDeleted){
var params = {
TableName : 'TableName',
Key: {
HashKey: 'hashkey',
NumberRangeKey: 1
}
};
dataToBeDeleted.forEach(item=>
var chain = Promise.resolve();
chain = chain.
then(()=>{
documentClient.delete(params, function(err, data) {
if (err) console.log(err);
else console.log(data);
});
}).then(() => delay(10));
}
);