I want to generate the following xml using the xml export function which will get its data from a db query which uses two tables, machines and images. They are linked via a left join.
indent preformatted text by 4 spaces
<Root>
<Item>
<MakeCol>TestMake</MakeCol>
<ModelCol>TestModel</ModelCol>
<Files>
<ImageCol>image1</ImageCol>
<ImageCol>image2</ImageCol>
<ImageCol>image3</ImageCol>
</Files>
<Item>
</Root>
If I query machines and get a result for a single machine with three images I get the following result as expected;
I’m still struggling to work out an answer to the above. I have also considered I might be able to get the result I require using a nested repeat region but can’t seem to work it out for my particular scenario.
Just to clarify what I’m trying to achieve, I need to end up with an XML output that shows;
I know I need a query to list my machines make and model and then I think a repeat of the images belonging to each machine.
The machine query would have a condition to show only those machines required but I can’t figure out how I get the images per machine to list in a way the XML output would like similar to the above.
Sorry I don’t have a lot of time to analyse this. My idea would be using the Repeat step, and for each machine use the .where() formatter to find all images of that machine, so for each machine you get an array of images
// 2 database queries: machines and images
Repeat machines
Set Value images = images.where('machine_id', '==', id)
I’m sorry but I don’t understand where I set in Wappler.
Set Value images = images.where(‘machine_id’, ‘==’, id)
I already tried a query with the two tables with an inner join, and I can get a result of a machine that has multiple images associated with it.
The issue is if I then group by the id of the machine to get a single row I only see one image column when what I really want are all the images shown on columns.