fromThe Code Barbarian
10 hours agoUsing Tries to Autocomplete MongoDB Queries in Node.js
Autocomplete seems like one of the easiest features to build. You take the user's input, loop through your list of options, and filter anything that starts with the same prefix: const matches = words.filter(w => w.startsWith(prefix)); And that works for small lists of text. But once your dataset gets large, or your completions come from structured text (like user.address.city or $gte), simple loops start to fall short.
JavaScript

