summaryrefslogtreecommitdiff
path: root/jstests/core/list_collections_name_only.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/list_collections_name_only.js')
-rw-r--r--jstests/core/list_collections_name_only.js55
1 files changed, 27 insertions, 28 deletions
diff --git a/jstests/core/list_collections_name_only.js b/jstests/core/list_collections_name_only.js
index dd50398bcba..9a89fed9e20 100644
--- a/jstests/core/list_collections_name_only.js
+++ b/jstests/core/list_collections_name_only.js
@@ -1,34 +1,33 @@
// Test nameOnly option of listCollections
(function() {
- "use strict";
+"use strict";
- var mydb = db.getSiblingDB("list_collections_nameonly");
- var res;
- var collObj;
+var mydb = db.getSiblingDB("list_collections_nameonly");
+var res;
+var collObj;
- assert.commandWorked(mydb.dropDatabase());
- assert.commandWorked(mydb.createCollection("foo"));
- res = mydb.runCommand({listCollections: 1, nameOnly: true});
- assert.commandWorked(res);
- collObj = res.cursor.firstBatch[0];
- // collObj should only have name and type fields.
- assert.eq('foo', collObj.name);
- assert.eq('collection', collObj.type);
- assert(!collObj.hasOwnProperty("idIndex"), tojson(collObj));
- assert(!collObj.hasOwnProperty("options"), tojson(collObj));
- assert(!collObj.hasOwnProperty("info"), tojson(collObj));
-
- // listCollections for views still works
- assert.commandWorked(mydb.createView("bar", "foo", []));
- res = mydb.runCommand({listCollections: 1, nameOnly: true});
- assert.commandWorked(res);
- print(tojson(res));
- collObj = res.cursor.firstBatch.filter(function(c) {
- return c.name === "bar";
- })[0];
- assert.eq('bar', collObj.name);
- assert.eq('view', collObj.type);
- assert(!collObj.hasOwnProperty("options"), tojson(collObj));
- assert(!collObj.hasOwnProperty("info"), tojson(collObj));
+assert.commandWorked(mydb.dropDatabase());
+assert.commandWorked(mydb.createCollection("foo"));
+res = mydb.runCommand({listCollections: 1, nameOnly: true});
+assert.commandWorked(res);
+collObj = res.cursor.firstBatch[0];
+// collObj should only have name and type fields.
+assert.eq('foo', collObj.name);
+assert.eq('collection', collObj.type);
+assert(!collObj.hasOwnProperty("idIndex"), tojson(collObj));
+assert(!collObj.hasOwnProperty("options"), tojson(collObj));
+assert(!collObj.hasOwnProperty("info"), tojson(collObj));
+// listCollections for views still works
+assert.commandWorked(mydb.createView("bar", "foo", []));
+res = mydb.runCommand({listCollections: 1, nameOnly: true});
+assert.commandWorked(res);
+print(tojson(res));
+collObj = res.cursor.firstBatch.filter(function(c) {
+ return c.name === "bar";
+})[0];
+assert.eq('bar', collObj.name);
+assert.eq('view', collObj.type);
+assert(!collObj.hasOwnProperty("options"), tojson(collObj));
+assert(!collObj.hasOwnProperty("info"), tojson(collObj));
}());