mongoose find() document with two fields with one search parameter
<p>My node model contains following properties </p>

<pre><code>firstName
lastName
age
address
</code></pre>

<p>I need to use mongoose find functions to filter user with firstName and lastName.</p>

<p>My UI pass only one search parameter. Data should filter as follows</p>

<p>'fistName' like 'search parameter' &amp; lastName like 'search Parameter'. </p>

<p>I pass following object to find function.It did not work for me. </p>

<pre><code>var criteria = {
    'firstName' : req.body.customerName ? { $regex: req.body.customerName, $options: 'i' } : null ,
    'lastName' : req.body.customerName ? { $regex: req.body.customerName, $options: 'i' } : null 
};
</code></pre>