Skip to content

Instantly share code, notes, and snippets.

View alfonsodguez's full-sized avatar
🌱
Developing

Alfonso Cobelas alfonsodguez

🌱
Developing
View GitHub Profile
@maknahar
maknahar / mongo-duplicate-delete
Last active January 23, 2024 13:43
Query to find and delete duplicate records from Mongodb (Works for millions of records)
/** Create a array to store all duplicate records ids*/
var duplicates = [];
/** Start Aggregation pipeline*/
db.collection.aggregate([
{
$match: { /** Add any filter here. Add index for filter keys*/
filterKey: {
$exists: false
}