title: How to query firebase items with specific reference type
body: <p>I have a parent collection <code>categories</code> and it child collection <code>directories</code>
  <code>Directories</code> connected with <code>Categories</code> via <code>Category</code> property</p>
  
  <p><a href="https://i.stack.imgur.com/n61gB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n61gB.png" alt="enter image description here"></a></p>
  
  <p>I want to query all directories with category equal to <code>level</code></p>
  
  <pre><code>this.firestore
        .collection&lt;any&gt;('directories', ref =&gt; ref.where('categories', '==', 'levels'))
        .get()
        .pipe(
          map(x =&gt; {
            const out: [] = [];
            x.forEach(y =&gt; {
              out.push(y.data());
            });
            return out;
          })
        );
  </code></pre>
  
  <p>I am getting an empty array in return. How would you fix that?</p>
  
  <p><strong>UPDATE</strong> based on the <a href="https://stackoverflow.com/a/54862990/2926340">answer</a> provided by @renaud-tarnec:</p>
  
  <pre><code>const categoryDocRef = this.firestore.doc('categories/levels');
  this.firestore
        .collection&lt;any&gt;('directories', ref =&gt; ref.where('categories', '==', categoryDocRef))
        .get()
        .pipe(
          map(x =&gt; {
            const out: [] = [];
            x.forEach(y =&gt; {
              out.push(y.data());
            });
            return out;
          })
        );
  </code></pre>
  
  <p>Now having an error <code>core.js:15713 ERROR Error: Function Query.where() called with invalid data. Unsupported field value: a custom AngularFirestoreDocument object</code></p>