How to deal with complex data?

I have 3 tables:
Entity
Snippet type
Snippets

Each entity can have multiple snippets of text, and each snippet has a type

I need to show a list of the entities, and for each one show each of their snippets w/ types.

My query returns as many rows for an entity as it has snippets… but I only want the data from Entity to show once, and all of the snippet/snippet type data for that entity to be shown in its row.

I can think of 2 ways to do this and can’t figure out how to do either of them in Appsmith:

Option 1) Split the query into 2 separate queries. Show a list of entities with one query, and in each row show snippet data from a second query based on entity id.

Option 2) Take the combined data from the query I’ve been working with and transform the data somehow that Appsmith can then display the way I need.

@emgm I think Option 2) would be the way forward. Here’s how to merge objects in an array based on a key - Merge JavaScript objects in array with same key - Stack Overflow.

I also tested it out to check. Please see the screenshot attached. Let me know if that is not what you are trying to achieve.