title: Delete all items in Dynamodb using Lambda?
body: <p>Using Lambda (node.js) - how to delete all the items in the Dynamodb table? </p>
  
  <p>There are 500K rows in the table </p>
  
  <p>I have tried using scan method and then loop through each item and then using delete method. It only allow up to 3000 rows only. </p>
  
  <p>Code</p>
  
  <pre><code>exports.handler = function(context, callback) {
    getRecords().then((data) =&gt; {
      data.Items.forEach(function(item) {
        deleteItem(item.Id).then((data1) =&gt; {
  
        });
      });
    });
  };
  
  var deleteItem = function(id) {
    var params = {
      TableName: "TableName",
      Key: {
        "Id": id
      },
    };
  
    return new Promise(function(resolve, reject) {
      client.delete(params, function(err, data) {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      });
    });
  }
  
  
  function getRecords() {
    var params = {
      TableName: 'TableName',
      IndexName: 'Type-index',
      KeyConditionExpression: 'Type = :ty',
      ExpressionAttributeValues: {
        ':ty': "1"
      },
      ProjectionExpression: "Id",
    };
  
    return new Promise(function(resolve, reject) {
      client.query(params, function(err, data) {
        if (err) {
          reject(err);
        } else {
          resolve(data);
        }
      });
    });
  }
  </code></pre>