title: Multiple Counts with single query in mongodb
body: <p>I am new to Mongo Db and would appreciate some help with this query. I have been sifting through posts here for the past couple of days tearing my hair to see if I could find anything related to my query but with no luck. </p>
  
  <p>I have a collection with documents similar in structure to below : </p>
  
  <pre><code>_id: xyz
  Movieid: 123
  MovieName: Titanic
  ReleaseDate: 2000-01-01
  
  _id: uvw
  Movieid: 456
  MovieName: Titanic II
  ReleaseDate: 2018-01-01
  
  _id: pqr
  Movieid: 789
  MovieName: Titanic III
  ReleaseDate: 
  </code></pre>
  
  <p>I would like to achieve the output as counts for totalmovies, movies with release date, and movies without release date in 3 seperate columns as below:</p>
  
  <pre><code>Total   |   Released  |     UnReleased
   3      |       2     |          1
  </code></pre>
  
  <p>I was able to write individual queries to execute the counts, but I am unable to successfully consolidate all that into a single query. The end goal is to create one view producing these counts as output. I have tried using operators such as $and, but can't seem to get the query to work as desired....this is as far as I got :</p>
  
  <pre><code>db.getCollection("Movies").aggregate({
    "$and": [
      { "$match": { "ReleaseDate": { "$exists": true } }},
      { "$count": "Total" },
      { "$match": { "ReleaseDate": { "$exists": true, "$nin": [""] } }},
      { "$count": "Released" },
      { "$match": { "ReleaseDate": { "$exists": true, "$in": [""] } }},
      { "$count": "Unreleased" }
    ]
  })
  </code></pre>