title: MongoDB aggregation, find non unique double fields if those existed
body: <p>I have MongoDB collection with something like this:</p>
  
  <pre><code>{ "parentId": "5d304431fdfd02eacf7d5dce", "name": "test" }
  { "parentId": "5d304431fdfd02eacf7d5dce", "name": "test" }
  { "parentId": "5d304431fdfd02eacf7d5dce", "name": "test" }
  { "name": "test"}
  { "name": "test"}
  { "parentId": "5d02033efdfd02580e04570e", "name": "test4" }
  { "parentId": "5d02033efdfd02580e04570e", "name": "test5" }
  { "parentId": "5d02033efdfd02580e04570e", "name": "test5" }
  </code></pre>
  
  <p>I need to find all non-unique bunch of 2 fields values: "parentId" &amp; "name".
  But the main problem - there are documents without one of needed fields(exemple).</p>
  
  <p>I`m stuck on query:</p>
  
  <pre><code>db.default.aggregate([
    {
      "$group": {
        "_id": {
          "parentId": "$parent",
          "name": "$name"
        },
        "uniqueIds": {
          "$addToSet": "$_id"
        },
        "count": {
          "$sum": 1
        }
      }
    },
    {
      "$match": {
        "count": {
          "$gt": 1
        }
      }
    }
  ])
  </code></pre>
  
  <p>So, I would like to get on finish:</p>
  
  <pre><code>{ "parentId": "5d304431fdfd02eacf7d5dce", "name": "test", count: "3" }
  { "parentId": "5d02033efdfd02580e04570e", "name": "test5", count: "2" }
  </code></pre>