- node express mongoose 多条件模糊查询
// 模糊查询
router.get('/searchSome',(req, res, next)=>{
let regexp=new RegExp(req.query.keyword,'i')
console.log(req.query.keyword);
Product.find({$or:[
{title:{$regex:regexp}},
{description:{$regex:regexp}},
{details:{$regex:regexp}}
]},(err,doc)=>{
if(err){
res.send({
isSuccess: false,
msg:"查询失败"
})
}
if(doc){
res.send({
isSuccess: true,
data:doc
})
}
})
})