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

111
Views
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 answers
Answer question

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