MongoDB query with multiple conditions
<p>I have data with multiple documents :</p>

<pre><code>{
 "_id" : ObjectId("57b68dbbc19c0bd86d62e486"),
 "empId" : "1"
 "type" : "WebUser",
 "city" : "Pune"
}
{
 "_id" : ObjectId("57b68dbbc19c0bd86d62e487"),
 "empId" : "2"
 "type" : "Admin",
 "city" : "Mumbai"
}
{
 "_id" : ObjectId("57b68dbbc19c0bd86d62e488"),
 "empId" : "3"
 "type" : "Admin",
 "city" : "Pune"
}
{
 "_id" : ObjectId("57b68dbbc19c0bd86d62e489"),
 "empId" : "4"
 "type" : "User",
 "city" : "Mumbai"
}
</code></pre>

<p>I want to get data according to my multiple conditions :</p>

<pre><code>condition 1:- {"type" : "WebUser", "city" : "Pune"}

condition 2:- {"type" : "WebUser", "city" : "Pune"} &amp; {"type" : "User", "city" : "Mumbai"}
</code></pre>

<p>I want below result when run condition 1 :</p>

<pre><code>    {
     "_id" : ObjectId("57b68dbbc19c0bd86d62e486"),
     "empId" : "1"
     "type" : "WebUser",
     "city" : "Pune"
    }
</code></pre>

<p>When I run second condition :</p>

<pre><code>{
  "_id" : ObjectId("57b68dbbc19c0bd86d62e486"),
  "empId" : "1"
  "type" : "WebUser",
  "city" : "Pune"
}
{
  "_id" : ObjectId("57b68dbbc19c0bd86d62e489"),
  "empId" : "4"
  "type" : "User",
  "city" : "Mumbai"
}
</code></pre>

<p>I want above result by one query,</p>

<p>Currently I am using below aggregate query,</p>

<pre><code> db.emp.aggregate([
     { $match: { '$and': [
         {"type" : "WebUser", "city" : "Pune"}, 
         {"type" : "User", "city" : "Mumbai"}
     ] } },
     { $group: { _id: 1, ids: { $push: "$empId" } } }
 ])
</code></pre>

<p>Above query work for first condition &amp; fails for other. Please help me.</p>