Firestore Collection Group

In addition to being able to query Firestore collections and sub-collections, my company would like to be able to query Collection Groups.

An example use case schema in which we want to see all Users across all Organizations (ie, the Users Collection Group):

Organizations/<org_id>/Users

Currently we need two tables (Organizations, Users) with chained queries and we still only see Users in the context of their Organization.

3 Likes

Hey @kamillamagna, and welcome to the community! Just to make sure I’m understanding correctly, you’re referring to these? (released about a year ago) https://firebase.googleblog.com/2019/06/understanding-collection-group-queries.html

Yeah, I linked to that in my original request.

LOL I did not put 2+2 together there. I’ll share this with the team :slight_smile:

1 Like

Just wondering if this made it to the roadmap or if there’s a way to use custom js (https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query)

@chrisattrove this should get released this week :slight_smile:

1 Like

It looks like this feature got released; however, the implementation makes it possible to select only the top-level collections for querying which defeats the purpose of collection group querying. I am excited to use this once I can input the correct sub-collection to collection group query. Any ETA on the fix for this? It seems like a nice short-term fix would be to allow users to type in a custom collection name so we aren’t bound to the ones that retool can find?

Hey @andrewbeckman! You are correct - we’re still working the kinks out so we haven’t updated the thread yet. We’ll update the dropdown to show all subcollections, which, to your point, is literally the whole point of collection group queries :slight_smile: - when that’s done I’ll update the thread. Ideally this week.

Another thing - we’re thinking about adding a raw query editor that will allow you to write raw queries via the Firebase JS SDK. That will help us support batched writes, but also give you the ability to write anything that Retool doesn’t quite support yet!

@andrewbeckman this should be fixed now! Let me know if it’s working as expected

Update for the whole topic - you can now query Firebase collection groups in Retool! You can select “query collection group” from the action type dropdown, choose your collection group name, and set other query params like limits.