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

189
Vistas
Executing Prisma query in loop: Promise { <pending> }

My code:

const getStats = async (projects) => {
  return projects.map(async (project) => {
    const count = await db.ping.count({
      where: { projectId: project.id },
    })
    console.log("Result is: " + count)
    return count
  })
}

The return value (there are two different projects, so two elements are correct):

[ Promise { <pending> }, Promise { <pending> } ]

If I understand that correctly, my outer promise when I call the function gets resolved correctly. Hence the array itself is not wrapped in a Promise. However, my two values still seem to be wrapped in a promise. The weird thing is that the console.log calls output the correct count number for each project, without any Promises:

Result is: 8
Result is: 1

Can anyone help me out here?

about 4 years ago · Juan Pablo Isaza
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