function handleBatchDeletes(tableName, items, callback) {
  if (!items.length) {
    callback()
  }
  const deleteItems = formatDynamoBatchDelete(items)
  // chunk items into 25 item arrays (Dynamo batch limit batchWrite)
  const batches = chunk(deleteItems, 25)
  var params = {
    RequestItems: {},
    ReturnConsumedCapacity: "NONE",
    ReturnItemCollectionMetrics: "NONE"
  }
  var returnData = []
  var count = 0
  batches.forEach((batch, i) => {
    params.RequestItems[tableName] = batch
    db.batchWrite(params, function(error, data) {
      if (error) return callback(error)
      console.log(`batch #${i} complete. ${batch.length} items removed from DB`)
      count++
      if (count === batches.length) {
        // last batch, callback and finish
        callback()
      }
    })
  })
}
/* batchUpdate loop for Dyanmo bulk modifications */
batchUpdate loop for Dyanmo bulk modifications
batchUpdate loop for Dyanmo bulk modifications
function handleBatchDeletes(tableName, items, callback) {
  if (!items.length) {
    callback()
  }
  const deleteItems = formatDynamoBatchDelete(items)
  const batches = chunk(deleteItems, 25)
  var params = {
    RequestItems: {},
    ReturnConsumedCapacity: "NONE",
    ReturnItemCollectionMetrics: "NONE"
  }
  var returnData = []
  var count = 0
  batches.forEach((batch, i) => {
    params.RequestItems[tableName] = batch
    db.batchWrite(params, function(error, data) {
      if (error) return callback(error)
      console.log(`batch #${i} complete. ${batch.length} items removed from DB`)
      count++
      if (count === batches.length) {
        callback()
      }
    })
  })
}
function handleBatchDeletes ( tableName , items , callback ) { if ( ! items . length ) { callback ( ) } const deleteItems = formatDynamoBatchDelete ( items ) const batches = chunk ( deleteItems , 25 ) var params = { RequestItems : { } , ReturnConsumedCapacity : "NONE" , ReturnItemCollectionMetrics : "NONE" } var returnData = [ ] var count = 0 batches . forEach ( ( batch , i ) => { params . RequestItems [ tableName ] = batch db . batchWrite ( params , function ( error , data ) { if ( error ) return callback ( error ) console . log ( ` ${ i } ${ batch . length } ` ) count ++ if ( count === batches . length ) { callback ( ) } } ) } ) }
batchUpdate loop for Dyanmo bulk modifications
batchUpdate loop for Dyanmo bulk modifications
// chunk items into 25 item arrays (Dynamo batch limit batchWrite) // last batch, callback and finish