title: How to find records in single projection query in mongodb based on regex expression in aggregation?
body: <p>I have a collection that name is <strong>web_events</strong></p>
  
  <p>and data is saved in something below structure.</p>
  
  <pre><code>{
      "subscriber_id" : "amit",
      "event" : "login"
  },
  {
      "subscriber_id" : "manish",
      "event" : "login"        
  },
  {
       "subscriber_id" : "manish",
      "event" : "page_view"        
  },
  {
      "subscriber_id" : "manish",
      "event" : "add_to_cart"       
  }
  </code></pre>
  
  <p>and i want to find out how many user do (login) event
  and how many user do (login,add_to_cart) both events</p>
  
  <p>output would be like ....
  ** (login) event count -  2, users and (login,add_to_cart) event count-- 1 user
  in one query** </p>
  
  <p>I am using two query for this....
  <strong>for login below query</strong> </p>
  
  <pre><code>db.web_events.aggregate([{$group:{_id:{subscriber_id:"$subscriber_id"},myfield:{$push:{$concat:["$event"]}}}},{$project:{"results":{$reduce:{input:"$myfield",initialValue:'',in:{$concat:["$$value","$$this"]}}}}},{$match:{results:{$regex:/.*login.*/}}}]);
  </code></pre>
  
  <p>and <strong>login and add_tocart</strong></p>
  
  <pre><code>db.web_events.aggregate([{$group:{_id:{subscriber_id:"$subscriber_id"},myfield:{$push:{$concat:["$event"]}}}},{$project:{"results":{$reduce:{input:"$myfield",initialValue:'',in:{$concat:["$$value","$$this"]}}}}},{$match:{results:{$regex:/.*login.*add_to_cart.*/}}}]);
  </code></pre>
  
  <p>I want to run both the aggregations in single projection query.</p>
  
  <p>Any help is appreciated.</p>