From aa0c365326b0d033e30f874e3315ac2cd3c46307 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 7 Sep 2014 14:34:04 -0600 Subject: [PATCH] wip(indexes): starter code for handling duplicate accounts #3986 --- database_reports/duplicate_indexes.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 database_reports/duplicate_indexes.js diff --git a/database_reports/duplicate_indexes.js b/database_reports/duplicate_indexes.js new file mode 100644 index 0000000000..0e7c0905ee --- /dev/null +++ b/database_reports/duplicate_indexes.js @@ -0,0 +1,14 @@ +db.users.aggregate([ + { $group: { +// _id: { "auth.local.username": "$auth.local.username" }, +// _id: { "auth.facebook.id": "$auth.facebook.id" }, + _id: { "auth.local.email": "$auth.local.email" }, + uniqueIds: { $addToSet: "$_id" }, + count: { $sum: 1 } + }}, + { $match: { + count: { $gt: 1 } + }} +]).forEach(function(user){ + // handle duplicates. likely, delete the accounts with older lastCron, or with the starter tasks. +}) \ No newline at end of file