[Solved] Code to check for duplicates in database and only displaying the newest on repeater (based on updated date)

Albert, this is going to take some extensive coding anyway that you choose to do it, but it is doable. Below is an example that isolates the duplicate entries utilizing the aggregate function, and then re-queries the collection to return all of the records with those emails, so a further process can easily find the newer record and display that. The newer record displays first in results2.

Perhaps, you could run a function like this on your data prior to loading the repeater and write to a field called “dupl” that would flag the older record. The repeater gathering query would then have a condition like:

 .ne("dupl",true). 

Hopefully, these are some ideas that get you further down the road …

export async function FindDupls(){
    let having = wixData.filter().gt("count", 1);
    let results,results2;
    results = await   wixData.aggregate("collection1")
    .group("email")
    .count()
    .ascending("email")
    .having(having)
    .run();
    if (results) {
     console.log("results:", results);
     let emailArray = results.items.map(a => a.email);
     console.log("emailArray", emailArray);
     results2 = await wixData.query("collection1")
        .hasSome("email", emailArray)
        .ascending("email")
        .find();
        if (results2){
            console.log("results2", results2);
        }
    }
}