Add Field Value with the same Title and display on Repeater

I need help with this one.

I have a repeater, something like this.

Store Name                Quantity          Amount

Now I need to get results from a collection “Stores”.
Store Name must be unique to be displayed in the repeater, and all results with the same Store Name the Quantity and Amount field values must be sum up.

Ex.
Results:

Store Name        Quantity      Amount
Store A             5            50
Store B             10           100
Store A             2            20
Store C             5            50
Store B             20           200

I need the repeater to display:

Store Name        Quantity      Amount
Store A             7            70
Store B             30           300
Store C             5            50

Hope someone can help. Thanks

You can use the aggregate() to achieve what you want. Read Corvid: Working with Aggregations in the Data API to learn how aggregates can solve your problem.

very helpful, thank you

I’m having problems with the _id , it would not accept strings with spaces.

like my store name Store A , it has to be StoreA for the _id
but I need to display it as Store A