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

147
Views
Async Delay in sending data

I required all the models and wanted to send all the static data from the database(Mongo) to a single endpoint /getall API. This is the controller file of the route I need to optimise. It's running fine in Postman but there is a delay. Is there any way to fetch the data faster like without using async and await ?

allController.js

const initiative = require("../Models/initiativeModel");
const event = require("../Models/eventSchema");
const collaborator = require("../Models/collaboratorModel");
const speaker = require("../Models/speakerModel");
const chairman = require("../Models/chairmanModel");
const management = require("../Models/ecellHeadsModel");
const faqs = require("../Models/faqModel");
const startup = require("../Models/startupModel");



exports.getAll = async(req, res,next) =>{
    const initiativesPromise = initiative.find();
    const eventsPromise =  event.find()
    const collabPromise =  collaborator.find()
    const speakPromise =  speaker.find()
    const chairPromise =  chairman.find()
    const managePromise =  management.find()
    const faqPromise =  faqs.find()
    const startupsPromise =  startup.find()

    const initiatives = await initiativesPromise.exec()
    const events =      await eventsPromise.exec()
    const collab =      await  collabPromise.exec()
    const speak =       await speakPromise.exec()
    const chair =       await chairPromise.exec()
    const manage =      await managePromise.exec()
    const faq =         await faqPromise.exec()
    const startups =    await startupsPromise.exec()

    return res.status(200).json({
                                        "events": events,
                                        "initiatives": initiatives,
                                        "collaborators": collab,
                                        "speakers": speak,
                                        "chairman": chair,
                                        "management": manage,
                                        "faq": faq,
                                        "startups": startups
    })

> can Promise.all be a faster way than async and await?

    
}
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!