Pass a Parameter to a Firebase Query when mapping column value

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

  1. Inside the query I tried to use the i parameter but it doesn't work
  2. 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

  1. A way to execute a query and pass in the document Id that I want it to use
  2. 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 :wave: 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 :slightly_smiling_face:

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.

  1. 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?

  2. 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.

@DaneMackier

  1. Yes, definitely! Just to break it down, in the additionalScope example I shared I am passing my query every row's data (specifically the id) in at a time. I can access this in my query using {{ id }} or {{ idx }} (whatever you have named the values)
  2. Are you looking to display this returned data in a table? Linking this community post on **dynamically add table rows **in case that fits your use case :slightly_smiling_face:
1 Like

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.