title: Why can't I rename this object in my node application?
body: <p>I've got a node.js/express application communicating with a Postgres database using the <a href="https://www.npmjs.com/package/pg" rel="nofollow noreferrer">node-postgres</a> module. It's working with async/await, but if I rename the object being returned to anything other than <strong>{ rows }</strong>, it comes back undefined. Here is my code; note the comment right under the <code>async</code>, and above <code>const { rows } = ...</code>:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  const { Pool } = require('pg');
  const pool = new Pool({
    connectionString: 'postgresql://postgres@localhost/mydb'
  });
  
  router.post('/login', function(req, res, next) {
    var username = req.body.username;
    var password = req.body.password;
  
    (async () =&gt; {
      // if I rename this from "rows" to, say, "userdetails", it comes back undefined
      const { rows } = await pool.query(`
              SELECT id, password
              FROM myschema.users
              WHERE username = $1
              LIMIT 1;`,[username]);
  
      if (rows.length) {
        // check password, etc, etc.
        return res.status(200).send();
      } else {
        return res.status(401).send();
      }      
    })().catch(e =&gt; setImmediate(() =&gt; { 
      res.status(500);
      } 
    ));
  
  });
  
  module.exports = router;
  </code></pre>
  
  <p>I'm sure I'm missing something pretty basic here, but why can't I rename this? Does the pg module dictate somehow that the returned var/const must be named <code>{ rows }</code>? If so, how might I discover that? I set a breakpoint at the <code>await</code> and step through the code, but it's still unclear to me.</p>