Currently, I have the following route for a text search.
router.post("/visit", middleware.isLoggedin, function(req,res){
subject.find({Subject_Name: req.body.user} ).sort('Visit_date').exec(function(err,returnedsubjects){
if(err){
console.log(err);
} else {
console.log(returnedsubjects);
res.render("visit",{returnedsubjects: returnedsubjects);
}
});
});
It works fine. But as you can see the subject_name has to match exactly. I need "david" or "David" to find collections where the Subject_Name = "David Warner" for example.
Tried this suggestion. How to query MongoDB with "like"?. Did not work.
Tried this
subject.find({Subject_Name: /req.body.user/} )
and this
subject.find({"Subject_Name": /req.body.user/} )
no luck :(.
Any help is appreciated. Thanks!