title: Node Async db call returning promise
body: <p>I'm working on a node project with sqlite as my db.</p>
  <pre><code>function select_from_table(tablename, limit) {
  
    let arr = [];
    let sql = `SELECT id FROM ${tablename} WHERE Type='Real' LIMIT ${limit}`;
     db.each(sql, function (err, row) {
      console.log(row.PropertyId);
      arr.push(row.PropertyId);
    });
    return arr;
  }
  </code></pre>
  <p>when I ran:</p>
  <pre><code>console.log(select_from_table('myData', 4));
  </code></pre>
  <p>I get '[]'</p>
  <p>stepping through this I see that control goes right to return array and then goes back to the loop above to perform the select, so that the arr is never returned. I then tried:</p>
  <pre><code>async function select_from_table(tablename, limit) {
  
    let arr = [];
    let sql = `SELECT id FROM ${tablename} WHERE Type='Real' LIMIT ${limit}`;
     await db.each(sql, function (err, row) {
      console.log(row.PropertyId);
      arr.push(row.PropertyId);
    });
    return await arr;
  }
  </code></pre>
  <p>but this returns a promise. What's the best way to approach returning the selected result?</p>