Best answer

Using Zapier to get FireStore sub-collection ID's

  • 23 July 2020
  • 3 replies
  • 419 views

Userlevel 1

I'm using Zapier to look up user information in FireStore based on the user's email address. I have a Top Collection called "groups" which contain users. If I use the below query in Zapier and hard code the {GROUP_ID}, so that the path is "groups/{GROUP_ID}/users", then the query works. 
 

However, I won't know the GROUP_ID at the time of the query. I'm thinking I'll need to loop through all groups (since google's collection groups don't appear to be supported in Zapier). But in order to loop through the groups, I first need to get a list of all the GROUP_ID's.

Because the GROUP_ID's are the top level sub-collection, I can't seem to figure out how to get Zapier to return a list of all of them. Zapier requires that I specify a collection group (groups) and a field path, and cannot leave either blank.

Any help is much appreciated! Thanks!

icon

Best answer by PaulKortman 25 July 2020, 02:21

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +10

Hi @Ginny I’m not 100% familiar with firestore, but I get the basic concept of what you are trying to do. 

 

So let me just clarify, you cannot put just “groups” or “groups/” in the Collection field, correct?

 

Assuming that is the case, how often does the list of groups (aka group IDs) change? 

 

Does this firestore trigger run when a new group is created?

If so, OR if the groups don’t change that often you sould store the group IDs in a Google Sheet, and then use this tip to run through the rest of your zap for each group ID in that spreadsheet. 

 

These are jsut some ideas, hopefuly with some more clarification we can come up with a decent/workable workaround.

 

 

Userlevel 1

Hi @Paul

Thanks for your reply! We’ll get a new ID every time we onboard a new customer, so relatively frequently.

If I only put “groups” in the collection field, the query says that it cannot find results.

The googlesheet workaround could work, but it’s not ideal to duplicate all of our data over to googlesheets. I’d prefer to access it in Firestore.

Thanks for the suggestions though!

Userlevel 7
Badge +10

the alternative is looking into a direct API call to firestore. I think this is the right endpoint: https://firebase.google.com/docs/firestore/reference/rest/v1beta1/projects.databases.indexes/get

 

But you would need to develop an app on the Zapier platform or the CLI, both of which handle the Oauth2.0 required so it can access firebase/firestorm. This would then give you the ability to get the group IDs directly from firestore.