Removing duplicates in the dynamic page repeater were the repeater is already filtered.

I’m having the same issue. Could anyone please help me on this.

ISSUE HERE - This is a dynamic page which is loaded after a button click (so the data is already filtered being a dynamic page). Now that data is already filtered, I want to remove duplicates. The code below is removing duplicates from the database import but I want to remove duplicates from the filtered data in the repeater.

Bold ones are variables - varying as per my collection/usages.

CODE HERE -
import wixData from ‘wix-data’;
export function dataset _ready() {
wixData.query(" databasecollection “).limit(1000).find().then(results => {
$w(” # repeater ").data = Array.from(results.items.reduceRight((m, t) => m.set(t. myfieldkey , t), new Map()).values());
});
}

Please connect on this, Thanks!
Looking something like onreadyitems in the repeater were data is already imported/filtered and now applying wix code for removing duplicates.

Basically you can re-arrange repeaters data inside repeater’s onItemReady() function: https://www.wix.com/corvid/reference/$w.Repeater.html#onItemReady , but why don’t you just filter the necessary information inside $w.onReady() function and pass it to repeater just once?

Let’s say your dynamic page is loaded and you receive something like this using getCurrentItem https://www.wix.com/corvid/reference/wix-dataset.DynamicDataset.html#getCurrentItem :


/*  
 *  {
 *    "_id":                "fcec780a-3e37-4b64-8a66-37c552c53f99",
 *    "_owner":             "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
 *    "_createdDate":       "2017-05-01T17:19:03.823Z",
 *    "_updatedDate":       "2017-05-01T17:19:10.477Z",
 *    "title":              "Dr. ",
 *    "name":               "B",

 *    "link-dynamic-name":  "/myCollection/B",
 *    "items": [{name: "hello", _id: 12345}, {name: "world", _id: 12345678}]
 *  }
 */

Get the result.items, filter them according to your needs and set repeaters.data to that array.