79423673

Date: 2025-02-08 18:02:13
Score: 1.5
Natty:
Report link

Thanks to Estus Flask this has been solved:

Using const {rows} in my second query instead of const {user} everything is now behaving properly... i.e.:

  (async () => {
    const {rows} = await pool.query(`SELECT * FROM accounts WHERE username = '${req.body.username}'`);
    console.log(rows);
  })();

Just in case anyone else is having this issue!!!

Mureinik's answer is also good, but for completness for noobs like me, the other, beetter(?) way of putting the results into a variable name of your choice say varName should you really need to would be:

  (async () => {
    const {rows: varName} = await pool.query(`SELECT * FROM accounts WHERE username = '${req.body.username}'`);
    console.log(varName);
  })();

Thank you very much to Estus for solving this instantly in the comments!

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Paul