I everyone i have my SearchBar running to find by title but i want him to find or title or category how can i do it ? and is possible to implement the autocomplete ?
router.get('/', async (req, res) => {
if (req.query.search) {
const regex = new RegExp(escapeRegex(req.query.search), 'gi');
const books = await Book.find({ title: regex });
res.render('books/home', { books: books, user: req.user });
} else {
const books = await Book.find({});
res.render('books/home', { books: books, user: req.user});
}
});