node.js - mongodb text search partial match -


hii want perform query 2 different search terms 2 different fields .but none of code works .please . want perform below sql query in mongodb or mongoose:

select * customers title '%$title%' or location '%$location%'; 

i have tried codes given below none of these working @ all:

         ***1. first code*** var searchstring1 = req.body.location;   var searchstring2 = req.body.title;  customer.find({$or:[{ "location": /searchstring1/ },{ "title": /searchstring2/ }]}).exec(function(err,jobs){}           ***2. second code*** customer.find({"$or":[                 {"title":new regexp(req.body.title,'i')},                 {"location":new regexp(req.body.location,'i')}             ]}).exec(function(err,jobs){} 

please help


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -