thanhpk
9/21/2016 - 3:37 AM

Duplicate location finder

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);