I\'m trying to build a search from input received from a form.
router.get(\'/data\', function(req, res) { var firstName=req.body.firstName, lastName
To avoid checking each parameter independently you can loop through them.
var query = {}; for(var key in req.body){ //could also be req.query and req.params req.body[key] !== "" ? query[key] = req.body[key] : null; } mongoose.model('customers').find(query, function(err, customers){ })