filtering firebase documents with collections under them


I’m working with an Angular 6 application and a firebase database. I’m wondering how to filter for only documents from the database that have specific collections under them.

To elaborate: We have a collection called “Pending”. This collection has a bunch of documents under it. Under *some* of these documents, there is another collection called “Invites”. All other documents do not have this collection. I’d like to retrieve only the documents under “Pending” that have the “Invites” collection under them.

I came up with this:

    const docsWithInvites = [];

    this.firestoreService.col(‘Pending’).ref.get().then(p => { => {

        this.firestoreService.col(Pending/${}/Invites).ref.get().then(i => {

          if (i.size > 0)







But this seems overly complicated and inefficient. There must be a way to filter for the documents with the Invites collection under them with just one query. Something like:

This.firestroeService.col(‘Pending’).where(/*Invites exists*/);

Is there a way to do this?