Skip to content

Instantly share code, notes, and snippets.

@thanhpk
Created September 21, 2016 03:37
Show Gist options
  • Save thanhpk/06c87f02c9e19d3e209099fa9bde2156 to your computer and use it in GitHub Desktop.
Save thanhpk/06c87f02c9e19d3e209099fa9bde2156 to your computer and use it in GitHub Desktop.
Duplicate location finder
var n = 0;
var myCursor = db.warehouseproducts.find();
while (myCursor.hasNext()) {
var doc = myCursor.next();
var locationMap = {};
for (var i = 0 ; i < doc.locations.length; i++)
if (locationMap[doc.locations[i].location.str] !== undefined) {
printjson(doc._id);
n++;
break;
}
else locationMap[doc.locations[i].location.str] = 1;
}
print(n);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment