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

272
Visualizações
API slow - fast in MongoDb but when in API its much slower, maybe due to RegExp

I've noticed my API is slow. To return restaurants when searching on towns is around 4 seconds average, (even if there are only 10 results). Same search (without RegExp), direct on Mongo Atlas is a tenth of a second. Here is my javascript code. I'm using Express, Mongoose and RegExp in my js. Is there any way to speed this up pls? :

// Route to return all restaurants matching the searched name, returning all fields, using a collection that has collation//
app.route("/restaurants/:restaurantName")

  .get(function(req, res) {
    let partialToMatch = new RegExp(req.params.restaurantName, 'i');
    Restaurant.find({
      BusinessName: partialToMatch
    }, null, {
      limit: 25
    }, function(err, foundRestaurant) {
      if (foundRestaurant) {
        res.send(foundRestaurant)
      } else {
        res.send("No restaurants matching that title was found.");
      }
    });
  });
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