Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

403
Vistas
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

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For a SELECT query, the pg.Result rows is an empty array [] with rows.length === 0

The rowCount === 0 as well but this can be different in an INSERT/UPDATE query where it becomes the updated rows.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda