title: Passing empty query to mongoDB using $match
body: <p>I have a dataset that I'm trying to create dynamic queries with. This is a sample of the data set.</p>
  
  <pre><code>db.test.insert({
      "_id" : ObjectId("58e574a768afb6085ec3a388"),
      "place": "A",
      "tests" : [
          {
              "name" : "1",
              "evaluation" : [
                  {
                      "aHigh" : [1,2],
                      "aLow" : [ ],
                      "zHigh" : [ ],
                      "zLow" : [1,3]
                  },
                  {
                      "aHigh" : [1,4],
                      "aLow" : [2],
                      "zHigh" : [ 3],
                      "zLow" : [ ]
                  },
                  {
                      "aHigh" : [ ],
                      "aLow" : [1,2,3],
                      "zHigh" : [1,2,3,4],
                      "zLow" : [ ]
                  },]
              }
              ]
          })
  db.test.insert({
      "_id" : ObjectId("58eba09e51f7f631dd24aa1c"),
      "place": "B",
      "tests" : [
          {
              "name" : "2",
              "evaluation" : [
                  {
                      "aHigh" : [2],
                      "aLow" : [3 ],
                      "zHigh" : [ ],
                      "zLow" : [1,2,3,4]
                  },
                  {
                      "aHigh" : [ ],
                      "aLow" : [ ],
                      "zHigh" : [ ],
                      "zLow" : [3,4]
                  },
                  {
                      "aHigh" : [1,2],
                      "aLow" : [3,4],
                      "zHigh" : [ ],
                      "zLow" : [1,2,3,4]
                  },]
              }
              ]
          })
  </code></pre>
  
  <p>The setup in total uses <code>nodejs</code> and <code>angularjs</code>, but the question only pertains to <code>mongoDB</code>. I have a set of selector boxes populated with the values contained in each of a specific field. For example, <code>"place"</code> has a selector that contains the values <code>"A"</code> and <code>"B"</code>.</p>
  
  <p>The default behavior of the search boxes is that they have a placeholder and no selected data passed to the model. This means that when I pass the query on load using the output of the model to <code>mongoDB</code>, I'm actually passing a <code>{}</code>. However, when I make a selection in the search box, then it passes a value.</p>
  
  <p>In my <code>mongoDB</code> query, I must use <code>aggregate</code> (for reasons that exceed the scope of the question), and therefore I must use <code>$match</code>. Here is some sample code.</p>
  
  <pre><code>db.test.aggregate([
      { $match: { place: {$in: [ &lt;whateverQuery&gt; ]}}},
      { $unwind: "$tests"},
      { $sortByCount: "$tests.name"}
  ])
  </code></pre>
  
  <p>The expected output looks like this:</p>
  
  <pre><code>{ "_id" : "1", "count" : 1 }
  { "_id" : "2", "count" : 1 }
  </code></pre>
  
  <p>How can I modify my approach so that passing nothing to the query returns everything?</p>