Hi,
I have a retool app connected to a Firebase Database. It displays the collection I'm want, I can even get additional data for the values that I click on. There's only 1 thing that I'm not able to achieve and I think it should be quite simple to do.
Overview
I have a table that shows all the documents from my artists
collection. On the artist map I have a value called user_id
. I want to get some values from the userDocument matching that userId. I have already created a Firebase Query using action type Get Document By Id
that points to the users collection.
The Problem
I don't know how to pass user_id from the current row into my Query or reference it inside the query.
What I have tried
- Inside the query I tried to use the
i
parameter but it doesn't work
- Inside the value property of my column I have tried to execute the query and pass in a value {{ getUser(documentId: 'id1234').data.last_seen }} but that doesn't work
What do I need?
Any one of the following solutions will help me achieve my goal
- A way to execute a query and pass in the document Id that I want it to use
- A way to reference the current row of a table (not the selected row) to run the query for each row of information.
@DaneMackier
Hey there
You should have access to {{ i }}
if you use an Action Button to run this query. Would that work for your use case?
Hey Lauren,
That would not work. I want to run the query for each Row in the table with a value from the row in the table.
To be more specific. I want to run my getUser firebase query and pass in the user_id from documentsTable.data[i].user_id
@DaneMackier
Ah thank you for the clarification there! It sounds like making use of additionalScope
here would work 
Here is an example where I am triggering query6 for every row in my table and passing it the index I am on as well as the row id:
Thanks @lauren.gus I looked at that as well and didn't know how I would use the value of the returned data as the column value in that row. I'll definitely try this, but I still have a few questions.
-
So I can can pass in the user_id as an additionalScope value and then access it in my query using user_id as my documentId?
-
Does this mean in my mapped value for the column I would put (based on your example)
{{ query8[i].app_version }}
The idea being that. For each value column the query runs a getDocument firestore query with the user_id passed in and then uses the value from the result returned as the value of the column?
Based on this example it looks like the query gets all the data and returns a map so it should be possible. I just want to make sure that I'm thinking of using it the right way.
Awesome. Thanks @lauren.gus I will try this out as soon as possible and mark this as the answer when it works.
I appreciate all your time. Thank you.