diff options
author | James Wahlin <james@mongodb.com> | 2017-07-03 15:33:36 -0400 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2017-07-25 12:24:49 -0400 |
commit | 5dcaad5f137eebc1915c0fc7b5078da4aa86f915 (patch) | |
tree | 3994b41708bce7cf5cbc5b7c9ba422db77f9bfb3 /src/mongo/shell/explainable.js | |
parent | 079763d2cd06776edf81f3ecf6c32ab66d1742ec (diff) | |
download | mongo-5dcaad5f137eebc1915c0fc7b5078da4aa86f915.tar.gz |
SERVER-29371 DocumentSource classes should provide auth requirements
Diffstat (limited to 'src/mongo/shell/explainable.js')
-rw-r--r-- | src/mongo/shell/explainable.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/shell/explainable.js b/src/mongo/shell/explainable.js index 0dcc5c6d76e..795326ab9d0 100644 --- a/src/mongo/shell/explainable.js +++ b/src/mongo/shell/explainable.js @@ -92,13 +92,9 @@ var Explainable = (function() { // Explainable operations. // - /** - * Adds "explain: true" to "extraOpts", and then passes through to the regular collection's - * aggregate helper. - */ this.aggregate = function(pipeline, extraOpts) { if (!(pipeline instanceof Array)) { - // support legacy varargs form. (Also handles db.foo.aggregate()) + // Support legacy varargs form. (Also handles db.foo.aggregate()) pipeline = Array.from(arguments); extraOpts = {}; } @@ -113,6 +109,11 @@ var Explainable = (function() { extraOpts.explain = true; return this._collection.aggregate(pipeline, extraOpts); } else { + // The aggregate command requires a cursor field. + if (!extraOpts.hasOwnProperty("cursor")) { + extraOpts = Object.extend(extraOpts, {cursor: {}}); + } + let aggCmd = Object.extend( {"aggregate": this._collection.getName(), "pipeline": pipeline}, extraOpts); let explainCmd = {"explain": aggCmd, "verbosity": this._verbosity}; |