Hello, I’m trying to delete a massive duplicate records in my table about 10,000 to 20,000 records exist in my table. As i don’t know where to insert the proper condition if the records is duplicate by knowing they are older dates or not up-to-date/current date And I can’t delete them in one go due to script execute time.
// Read our table
var table = base.getTable("Weekly Metrics");
var query = await table.selectRecordsAsync ();
// Check whether any record in that table
// match the input
let duplicate = query.records.filter((record)=>{
return query.records.find((potentialDuplicate) => {
return record.getCellValue("Pages") === potentialDuplicate.getCellValue("Pages") && record.id !== potentialDuplicate.id;
//&& record.id !== potentialDuplicate.Id
})
});
// console.log(duplicate);
let updates = duplicate.map(update => {
return {
"id":update.id,
fields:{
"Duplicate?":true
}
}
});
while(updates.length > 0){
await table.updateRecordsAsync(updates.slice(0,50));
updates.slice(50);
}
