Firebase Realtime database key / value pair to table

Hi,

quite new to this so forgive my mistakes or missknowledge.

I need to map the below

"rootForTheQuery": {
"1677572271242_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "xxx",
"1677616477709_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "yyy",
"1677756607217_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "zzz"
}
Into a table, reason for this is beacause I need to be clickable and from the click get another query.

I have read:
https://docs.retool.com/docs/data-in-tables
https://docs.retool.com/docs/transformers

https://docs.retool.com/docs/javascript-in-retool#data-conversion-1

And tried the below

No luck as I do not understand what he wants and what I get from the query.

Without transformer I have the below

And with the below

I have it populated but each value is splitted in chars, one for each row and the db key is on the column instead

Any help please?

Hey @Bravo_Roi! Welcome to Retool and no apologies needed whatsoever :slight_smile:

Tables expect arrays of objects or objects of arrays, and it looks like

query.data.rootForTheQuery is returning just an object. Could you try something like:

{{ [query.data.rootForTheQuery] }}

in your query data field? If this doesn't work, could you share a screenshot of the state tab in your left panel expanded out to show the query.data.rootForTheQuery as much as possible?

Thanks Vic,

it looks like it does not understand to postprocess {{[]}} , instead it reads it as a DB location , returning


Even worst if I write it down as requested

Below what requested



Thank you.

Any help on this please? Still stuck on this and can't move forward

Something like this should help you get your data displayed in a table component:

If you want to access the uid from a selectedRow, you'd have to transform your data to look like this:

Then you should be able to do {{UsersTable.selectedRow.data.uid}}

Is this getting you any closer? If not, happy to step into your app to actually take a look at this :slight_smile:

const data = {"rootForTheQuery": {
"1677572271242_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "xxx",
"1677616477709_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "yyy",
"1677756607217_MA_CmTq3CoIZUMQS4ZqzjI0wN3uHZo1": "zzz"
}}

const final_obj = {'uid':[], 'letters':[]}
for(let i=0;i<Object.keys(data.rootForTheQuery).length;i++) {
  let key = Object.keys(data.rootForTheQuery)[i]
  final_obj.uid.push(key)
  final_obj.letters.push(data.rootForTheQuery[key])
}

return final_obj;

Excellent stuff Victoria. I appreciated the fact you took time to test the solution before posting it. It worked!!