Skip to content

Instantly share code, notes, and snippets.

@marvell
Created December 9, 2015 13:02
Show Gist options
  • Save marvell/7361c34a836a17f7628c to your computer and use it in GitHub Desktop.
Save marvell/7361c34a836a17f7628c to your computer and use it in GitHub Desktop.
db.NASA_MCDAODHD.aggregate([
{ "$group": {
"_id": { "uid": "$loc", "sid": "$dt" },
"dups": { "$push": "$_id" },
"count": { "$sum": 1 }
}},
{ "$match": { "count": { "$gt": 1 } }}
]).forEach(function(doc) {
doc.dups.shift();
db.NASA_MCDAODHD.remove({ _id: { "$in": doc.dups } });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment