regex - How do I execute 'like' statement using mongoose -
this question has answer here:
- mongoose.js: find user username value 11 answers
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
Post a Comment