I have a function here to search MongoDB using mongoose, but I would like it to find Brazil when I search for bra, Bra, Sil, sil, etc. I looked at the documentation and followed the example but it did not work, it does not return anything. Here is the code:
exports.postSearchCountry = (req, res, next) => {
const countryName = req.body.countryName
Country.find({
name: /countryName/i
})
.then(countries => {
res.render('country/countries', {
countries: countries
})
})
.catch(err => {
console.log(err)
})
}