skip to Main Content

how we can search via variable in mongodb in node.js

exports.findByTable = (req, res) => { console.log(req); const table = req.params.table; const text = req.params.text; Employee.find({[req.params.table]: "/.*"+[req.params.text]+".*/i"}) .then(data => { if (!data) res.status(404).send({ message: "Not found Employee with id " +[req.params.text]}); else res.send(data); })`your text` .catch(err => { res .status(500)…

VIEW QUESTION
Back To Top
Search