Issue when trying to apply get subcollection for each item of a table

Continuing the discussion from Firestore sub-collection:

Hi,
I'm interested in querying a sub-collection from firestore and the solution you proposed worked perfectly for one item.

However, I have a first table where I'm querying all of my items from firestore, and I would like in a column of my table, to display for each item the subcollection of the item. And I couldn't find a way of doing it.

When I'm trying to add login/{{table1.data[i]._id}}/sessions in my subcollection ID, it only works for the first item of the table, but it is not applying for each item of the table.

Is there a way of doing it ?

Hey @squero! You should be able to manage grabbing the subcollection for each table entry in a JS query and then use that data in a custom column in the table. We have some docs on this, here.

You can use the query that grabs all the items, and then fetch the subcollection for each item.

Pass the item id into the getSubcollection query as additionalScope:

Reference the additionalScope property in the query:

Use the new data in a custom column on the table:

If you add a trigger to the JS query onSuccess of the original query, it will run when that data is retrieved.

Let me know if you have any other issues getting this to work.

1 Like