Populating Nested Structures from a Query

Populating Nested Structures from a Query

Is it possible to populate a structure that contains another structure nested within it from an Advanced Query or even a Simple Query, peferably without using an Action?

For example to return the structure Orders that contains the structure Line Items.

At the moment the query is demanding an array to populate the nested structure.
Are there any examples available?

Hello Charles,

First of all, sorry by the late response.

Unfortunatelly is not possible to use nested structures in the output structures of the queries, so you'll need to develop some logic based on 'for each'.

You can check two examples here, and you can check the logic on the attached module.

Version 1 it is better than version 2, because you're doing only one query instead of doing one query inside the 'for each', that is not recomendable (in you case, if you have a huge number of orders, and each order has a huge number of line items, you can have performance issues).

Please, if you have more questions don't hesitate, we are here to help you!

Thank you!

Best Regards,

Nuno Roxo
I had the same issue a few weeks ago... and the solution was similar. 
1st - Query 
2nd - Foreach to iterate and populate the nested structure