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

115
Visualizações
Mongodb autocomplete

I am building app and I need to implement autocomplete for search. now I'am trying to implement it using regexp and I am not sure whether it is best way because for any new character input in the search bar I need to do new request, is there better and faster way? I am not using mongo atlas

server.get("/search", async (req, res) => {
try {
    var regex = new RegExp(`${req.params.name}`, 'i');
   
    const users = await User.find({name:regex});
   
    res.status(400).send(users);
} catch (error) {
    res.status(500).send({message:error.message});
}

})

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

In searches it is always recommended to use a Debouser, since it waits for the user to finish typing to make the request, your backend code is correct, you just need to implement the Debouser in the frontend:

Dependence debouser react: https://www.npmjs.com/package/use-debounce

you can put a timeout of 500 milliseconds, this will do the request when the user doesn't type for 500 milliseconds.

about 4 years ago · Santiago Gelvez Relatório
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