Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. var database = "sample";
  2. var collection = "tests";
  3.  
  4. var connections = [];
  5.  
  6. config = db.getMongo().getDB("config");
  7. config.shards.find().forEach(
  8. function (shard,_a,_i) {
  9. connections.push(new Mongo(shard["host"]));
  10. }
  11. );
  12.  
  13. db.getMongo().getDB(database).getCollection(collection).find().forEach(
  14. function (doc, _a, _i) {
  15. count = 0;
  16. onshards = [];
  17. connections.forEach(
  18. function(con, _a, _i) {
  19. if (con.getDB(database).getCollection(collection).find(doc).count()==1) {
  20. count += 1;
  21. onshards.push(con);
  22. }
  23. }
  24. );
  25. if (count > 1) {
  26. print("duplicate doc: "+doc['_id']+" found on: ");
  27. onshards.forEach(function(shard,_a,_i) {print(shard.toString())});
  28. }
  29. }
  30. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement