Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!