Displaying in a repeater the results of a query aggregate

I have a query/aggregate on a Table and I want to show the result in a repeater.

The table is collecting information about the use of our pages and information about what has been done on this page (view a photo, download a file,…)
The table “EventsLog” has fields “dateTime”, “context”, “element”, “process”, and the _id of course

The folowing query give me the expected result:

… datestart and datestop preparation
const dateFilter = wixData.filter().between(“dateTime”, dateStart, dateStop);

wixData.aggregate(“EventsLog”)
.limit(1000)
.filter(dateFilter)
.count()
.min(“_id”) //??? test
.group(“context”, “element”, “process”)
.ascending(“context”, “element”, “process”)
.run()
.then((results) => {
console.log(“results”);
console.log(results);
console.log(results.items[0].count);
console.log(results.items[0].process);
console.log(results.items[0].context);
console.log(results.items[0].element);

I have a repeater ($w(“#repeaterSummary”)) with columns.

        $w("#repeaterSummary").onItemReady(($item, itemData, index) => {
			console.log("repeater populate");
			$item("#textDatim").text = itemData.process;
			...
        });
        $w("#repeaterSummary").data = results.items;

This is not working. I understood that for this process to work, you need a unique id for each item, and aggregate does not give that!
I tested that with a manualy defined variable like
const items = [
{ _id: “1”, title: “Article 1” },
{ _id: “2”, title: “Article 2” },
{ _id: “3”, title: “Article 3” }
]; and it works. (if i delete the _id field, the process failed)
So my problem is to “add” a unique _id in the structure received.
I tested 2 ways:

  1. add a .min(“_id”) in the query definition. I receive a result with a unique id, but the name is min_id and not _id !!! so does not work!
  2. I tried to create a new result set, by creating a new array variable, and adding a _id field with a unique identifier, but do not know how to recreate the new resultset.
    I looked at something like
    let i = 0
    let ItemArray =
    let ItemOne =
    results.items.forEach((item) => {
    i++
    ItemOne = [
    { _id: i, …??? }
    ];
    ItemArray.push(ItemOne);
    })
    console.log(ItemArray);

What is wrong in my approach? A better way to do this?

In this example,

I have removed the filter ( too much messing around for my example) but it should be fine for your setup.
If you look at the results from the aggregate, you will see that the key for the id is ‘._idMin’

so you need to use item._idMin

wixData.aggregate("EventsLog")
    .limit(1000)
    //.filter(dateFilter)
    .count()
    .min("_id") // This is fine to include, but we won’t use it for the repeater.
    .group("context", "element", "process" )
    .ascending("context", "element", "process")
    .run()
    .then((results) => {
        console.log("Results from aggregate:");
        console.log(results);

        // Create a new array with a unique _id for each item
   const repeaterData = results.items.map((item) => {
    return {
        _id: item._idMin,  // Use _idMin from aggregation as the unique ID
        count: item.count,
        context: item.context,
        element: item.element,
        process: item.process
    };
});

Also the repeater can then be setup like this

 $w("#repeaterSummary").data = repeaterData;
        
        $w("#repeaterSummary").onItemReady(($item, itemData, index) => {
            console.log("Repeater populating item:", itemData);
            $item("#textDatim").text = itemData.process;  // Adjust this to match your repeater elements
            $item("#textContext").text = itemData.context;
            $item("#textElement").text = itemData.element;
            $item("#textCount").text = itemData.count.toString();
        });

For other who are reading this. The EventsLog is the id of a cms that is populated by velo coded events

Thanks, it look promising