summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2011-03-30 16:28:21 -0400
committerMathias Stearn <mathias@10gen.com>2011-03-30 16:28:21 -0400
commit50613b671861803260440b06dabdc29eac82506f (patch)
tree4cce8bf5b5ada7ae326791cb3aec575079cce841 /shell
parentb980e631d97249dcf22d0a61fefcb02655224f6e (diff)
downloadmongo-50613b671861803260440b06dabdc29eac82506f.tar.gz
validate() helper support for sharding SERVER-2849
Diffstat (limited to 'shell')
-rw-r--r--shell/collection.js16
-rw-r--r--shell/mongo_vstudio.cpp16
2 files changed, 32 insertions, 0 deletions
diff --git a/shell/collection.js b/shell/collection.js
index 01f34417f8c..28a7ec76e05 100644
--- a/shell/collection.js
+++ b/shell/collection.js
@@ -384,6 +384,22 @@ DBCollection.prototype.validate = function(full) {
var res = this._db.runCommand( cmd );
+ if (res.raw){
+ // sharded
+
+ res.valid = true;
+ for (key in res.raw) {
+ if (typeof(res.raw[key].valid) == 'undefined'){
+ // if any shard is using old-style output use regex test
+ res.valid = undefined;
+ break;
+ }
+ else {
+ res.valid &= res.raw[key].valid;
+ }
+ }
+ }
+
if (typeof(res.valid) == 'undefined') {
// old-style format just put everything in a string. Now using proper fields
diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp
index d50ded6e89c..fbcb1a16c6d 100644
--- a/shell/mongo_vstudio.cpp
+++ b/shell/mongo_vstudio.cpp
@@ -3185,6 +3185,22 @@ const StringData _jscode_raw_collection =
"\n"
"var res = this._db.runCommand( cmd );\n"
"\n"
+"if (res.raw){\n"
+"// sharded\n"
+"\n"
+"res.valid = true;\n"
+"for (key in res.raw) {\n"
+"if (typeof(res.raw[key].valid) == 'undefined'){\n"
+"// if any shard is using old-style output use regex test\n"
+"res.valid = undefined;\n"
+"break;\n"
+"}\n"
+"else {\n"
+"res.valid &= res.raw[key].valid;\n"
+"}\n"
+"}\n"
+"}\n"
+"\n"
"if (typeof(res.valid) == 'undefined') {\n"
"// old-style format just put everything in a string. Now using proper fields\n"
"\n"