I am trying to run a query and return the result rows in a function:
async function query(sql) {
  p(`sql: ${sql}`)
  let rows = await pool.query(sql)  // Notice the *await* here
  let r2 = rows.then( r => {
    debug(`nRows=${r.rows.length}`)
    return r.rows
  })
    .catch( err => {
      throw `Query [${sql}] failed: ${err}`
    })
    
  return rows
}
However the rows actually returns a Promise - instead of the actual results.  This is not making sense to me: then what is the await actually achieving in there ?  And then - how can the result be computed and returned by this function?
 
     
     
    