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

157
Views
How to run a query in a loop?

I want to execute a query in a forEach or map but I am not getting any data.

Database used is PostgreSQL.

I'm using pg to connect to the database.

const tables = ["api","users","countries","phone_number","profile_photo","role",];
let data = [];
tables.forEach(async (ele) => {
      let q = `select * from ${ele} ;`;
      let qd = await pool.query(q);
      data.push(qd);
});
res.json(data);
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!