title: How to do find all or get all in dynamo db in NodeJS
body: <p>I want to get all the data from a table in Dynamo DB in nodejs, this is my code</p>
  <pre><code>const READ = async (payload) =&gt; {
    const params = {
      TableName: payload.TableName,
    };
  
    let scanResults = [];
    let items;
    do {
      items = await dbClient.scan(params).promise();
      items.Items.forEach((item) =&gt; scanResults.push(item));
      params.ExclusiveStartKey = items.LastEvaluatedKey;
    } while (typeof items.LastEvaluatedKey != &quot;undefined&quot;);
  
    return scanResults;
  };
  </code></pre>
  <p>I implemented this and this is working fine, but our code review tool is   flagging red that this is not optimized or causing some memory leak, I just cannot figure out why, I have read somewhere else that scanning API from dynamo DB is not the most efficient way to get all data in node or is there something else that I am missing to optimize this code</p>