I am trying to build a simple Retool table using data from a Mongo Atlas DB. Everything works fine, except that when I query an embedded document inside my Mongo data, I get each row populated with:
{ "key1" : 23, "key2": 24, "key3": 25 }
In other words, it presents the JSON and the values are correct, but it doesn't split it into columns. What am I missing here? Do I need to use a Transformer.
Hello!
Hello!
I recorded a video with the same data integrating a table, see if it helps.
Thank you very much for taking the time to record this. I am still trying to figure this out.
1 Like
No need to thank me, I like to help and knowledge needs to be shared.
I will try to connect more with the Retool community on the Forum, so let's go!
If you still cannot identify the problem, I will suggest the following steps:
Steps in Retool
1 - Try to create another app, another query and validate in a simple scenario, for example one table and one query.
Mongo DB steps
1 - Try to create the same data setup directly
2 - Try to create more data scenarios
3 - Test various scenarios also in other queries in Retool after that
1 Like
Yes, that makes sense. The main problem seems to be that my MongoDB contains nested objects so it is more like:
{
"_id": {
"$oid": "634cbaed57ed982055e0ded9"
},
"date_str": "2022-10-16",
"data": {
"subdata1": 27.23,
"subdata2": 28.1,
"subdata3": 94.2
}
}
So, the problem is more how to extract elements from a subdocument like "data.subdata" and have each show up as a column in a table. This feels like it should be easy but I am missing something! 
Figured it out!
When creating the table column, in the Mapped Value field enter:
{{query1.data[i].data.subdata1}}
I do have to create a new column for each entry, but that is OK for my use case!
2 Likes