I have this search controller and I want to set it up to check every letter in search input but I don't know how to do it with regex.
module.exports.search = (req, res, next) => {
Character.find({
$or: [
{ firstName: req.query.search },
{ lastName: req.query.search }
]
})
.then(characters => {
res.status(200).send(characters);
})
.catch(next);
}
Also, I have tried with
{ firstName: /req.query.search/ }
, but it doesn't work. Any help would be great.