If you just need to display the data, and don’t need to transform/modify/reference it in any way, you could use format as text to iterate over the results and turn them into one consolidated list of texts. That way you’d only need a single repeating group, avoiding the nested groups entirely.
It’s a useful approach when you need to display multiple datatypes in a single repeating group. I use it on our app to display a consolidated, chronological statement of account to each of our clients, which pulls from several different financial datatypes in our db.
My preference is usually to use pipes “|” (gets a little more complex if you need to use regex) to separate entries, so that they can be split later, making them a little more (if not fully) dynamic in the output, just make sure to keep dates in reverse to allow sorting:
Modified format as text input for rg:
2024-01-01|user_1|feed_item,
2024-02-04|user_1|feed_item,
2024-01-02|user_2|feed_item
You then split this block text by comma and feed them into your rg, subsequently splitting out each field by the pipe to display them where you want them in your rg. This can then be sorted ascending/descending, which will go off the date at the start of the string.
Another upside to this method is that it makes for really easy filtering, as you can add in whatever search terms you want into each line, but just ignore them when splitting out what you display.
e.g.
2024-01-01|user_1|feed_item|feed_type|popularity|author|other,
2024-02-04|user_1|feed_item|feed_type|popularity|author|other,
2024-01-02|user_2|feed_item|feed_type|popularity|author|other
Even if you ignore everything after “feed_type”, you can still filter the results by checking if they contain the value of an input, which could be the author, popularity, other etc.
Upsides:
- Consolidated data
- Less repeating groups
- Easy date sorting
- Easy filtering
Downsides:
- Big loss of data modularity
- Depending on size it can be a slow operation (I calculate mine server side for that reason)