regex - How do I execute 'like' statement using mongoose -


this question has answer here:

i have data here:
{ _id: 1, url: "romeojuliet" }
{ _id: 2, url: "romeojuliet2" }
{ _id: 3, url: "oromeojuliet" }

this current code

exports.searchurl = function(req, res) {   var url = req.body.url;    content.find({ 'url': /^url/i}, function(err, doc) {   var returnvalue = doc;   if(doc == null) {     returnvalue = {};   }   if (err) return next(err)     return res.send(returnvalue);     }); }; 

expect req.body.url "romeojuliet"
code want show data contains "romeojuliet%",
in case _id 1 , 2 appear.

is possible?

make this:

exports.searchurl = function(req, res) {   var url = req.body.url;    content.find({ 'url': /^romeojuliet/i}, function(err, doc) {   var returnvalue = doc;   if(doc == null) {     returnvalue = {};   }   if (err) return next(err)     return res.send(returnvalue);     }); }; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -