【发布时间】:2017-05-14 10:21:14
【问题描述】:
我的节点模型包含以下属性
firstName
lastName
age
address
我需要使用 mongoose 查找函数来过滤带有名字和姓氏的用户。
我的 UI 只传递一个搜索参数。数据应按如下方式过滤
'fistName' 像'搜索参数' & lastName 像'搜索参数'。
我通过以下对象来查找函数。它对我不起作用。
var criteria = {
'firstName' : req.body.customerName ? { $regex: req.body.customerName, $options: 'i' } : null ,
'lastName' : req.body.customerName ? { $regex: req.body.customerName, $options: 'i' } : null
};
【问题讨论】: