title: MongoDB filter by array property only if it exists
body: <p>My database object has an optional property named <code>tags</code> which is a string array. I want to write a query that returns objects if they match one of these conditions:</p>
  
  <ol>
  <li>They don't have a <code>tags</code> property.</li>
  <li>They have a tags property that has at least one item included in another array called <code>queryTags</code></li>
  </ol>
  
  <p>From reading the documentation I came up with the following but it doesn't work:</p>
  
  <pre><code>let query = {
      tags: { '$or': [{'$exists': false}, {'$in': queryTags}]}
  }
  </code></pre>