Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var database = "sample";
- var collection = "tests";
- var connections = [];
- config = db.getMongo().getDB("config");
- config.shards.find().forEach(
- function (shard,_a,_i) {
- connections.push(new Mongo(shard["host"]));
- }
- );
- db.getMongo().getDB(database).getCollection(collection).find().forEach(
- function (doc, _a, _i) {
- count = 0;
- onshards = [];
- connections.forEach(
- function(con, _a, _i) {
- if (con.getDB(database).getCollection(collection).find(doc).count()==1) {
- count += 1;
- onshards.push(con);
- }
- }
- );
- if (count > 1) {
- print("duplicate doc: "+doc['_id']+" found on: ");
- onshards.forEach(function(shard,_a,_i) {print(shard.toString())});
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement