Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda