'How to check for node-postgres if no results

I am confused what exactly node-postgres postgres database returned if no records ?

try {
  const {
    rows: [user]
  } = await pool.query(`SELECT * FROM "users" WHERE username = $1 LIMIT 1`, [
    username
  ]);

  console.log('user', user);

  if (!user || typeof username !== 'undefined') return false;

  return await bcrypt.compare(password, user.password);
} catch (e) {
  console.log(e);
}

How to check if there is no user result



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source