How to use group by formatter in App Connect?

Wappler 4.8.2
OS: Mac - Intel Chip

Site: NodeJS

Problem:
If you add the option to group or unique to filter out duplicates it returns with information not showing, see images below:

This is with

search_products.data.query.data.groupBy(`id`)

this is with

search_products.data.query.data

You can see the difference when the group or unique is added.
Not quite sure what is causing the issue but this is the code for the table body

 <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="search_products.data.query.data.groupBy(`id`)" id="tableRepeat1" key="id">
            <tr class="mouse align-middle" dmx-on:click="flow1.run({supplierID: supplier, productID: id})">
                <td>
                    <img width="75" height="75" dmx-bind:src="image_url">
                </td>
                <td dmx-text="ssc"></td>
                <td dmx-text="title"></td>
            </tr>
        </tbody>

Any help would really be appreciated.

@Teodor @George is there any update on this, as it is something that I really need to get working

That’s not how you really use the group by function. You should bind the name of the property which you grouped the records by, inside the repeat region. It’s available as key inside the repeat.
If you want to access the rest of the properties you need to get them from the value.

is there any instructions on this I can read through as I am a little confused by what you are saying.

Hi Peter,
The group by function creates a new array with the value it is grouped by as the key. For example if you have some sales from a DB query:

[
{saleid:1, userid: 103, item: 5, saledate: '2022-04-25'},
{saleid:2, userid: 12, item: 5, saledate: '2022-04-25'},
{saleid:3, userid: 103, item: 5, saledate: '2022-04-25'},
{saleid:4, userid: 6, item: 5, saledate: '2022-04-25'},
{saleid:5, userid: 3, item: 5, saledate: '2022-04-25'},
{saleid:6, userid: 103, item: 5, saledate: '2022-04-25'},
{saleid:7, userid: 6, item: 5, saledate: '2022-04-25'}
]

and you want to list the sales by the user that recorded them you could use .groupby('userid')

This might give you something like this:

{
103: [
    {saleid:1, userid: 103, item: 5, saledate: '2022-04-25'},
    {saleid:3, userid: 103, item: 5, saledate: '2022-04-25'},
    {saleid:6, userid: 103, item: 5, saledate: '2022-04-25'}
],
6: [
    {saleid:4, userid: 6, item: 5, saledate: '2022-04-25'},
    {saleid:7, userid: 6, item: 5, saledate: '2022-04-25'},
],
etc...
}

Note how when you group, that user’s sales are in a new array underneath that needs to be repeated through

@gunnery,
Perhaps explain why you want groupby as part of the repeat expression. I’m not sure it is the correct/best way to achieve what you want.

Initial gut feeling is that you should use DISTINCT on the query producing the list if you are trying to rule out the same product shown twice.

thanks I’ve got it sorted now, I had to build a customer query with a group by ID in there and that has done the job :slight_smile: