Skip to content

Instantly share code, notes, and snippets.

@vidanov
Created April 13, 2019 18:19
Show Gist options
  • Save vidanov/1c962d65beb100fdaf86d3bd1a4b1739 to your computer and use it in GitHub Desktop.
Save vidanov/1c962d65beb100fdaf86d3bd1a4b1739 to your computer and use it in GitHub Desktop.
batchWriteItem
params = {
RequestItems: {},
};
params.RequestItems[process.env.BlamG2Table]=[];
var i=0;
response.data.forEach(element => {
i++;
if (element.Fields.blmw_task_type=='Review & Approve' && element.Fields.blmw_task_status == 'approved')
{ var dateC=new Date().toString();
//console.log(JSON.parse(element));
params.RequestItems[process.env.BlamG2Table].push({ PutRequest: {
Item: {"BlamId": {"S":element.ItemID}, "Source": {"S":"Blam"}, "DateCollected":{ "S": dateC },"Status":{"S":"In"}},
ConditionExpression: "attribute_not_exists(BlamId)"
}
})
}
});
await dynamo.batchWriteItem(params).promise(); // Add items to the table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment