mongoose实现模糊查询
看的官方文档没看懂,参考这篇文章搞懂了。
https://cnodejs.org/topic/50bea139637ffa41559191d9
就这这篇文章
例如:
var sreachKey = req.query.sreachKey;
var sreacKeyRegExp = new RegExp(sreachKey);
console.log(sreachKey);
Goods.find({'goodsname': sreacKeyRegExp}, function (err, goods) {
大概是这个样子,把参数和要查寻的正则表达式放进去就可以了。