Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda