2
I have a function here to do a search on Mongodb using Mongoose, but I would like him to find Brazil when I searched for bra, Bra, Sil, Sil, etc. I looked in the documentation and followed the example but it did not work, it does not return anything. Follows 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)
        })
    }
Thank you. In the example of the documentation of Mongoose they use a direct string, so it was not necessary to use the new Regexp
– Rodolpho