From 5dcaad5f137eebc1915c0fc7b5078da4aa86f915 Mon Sep 17 00:00:00 2001 From: James Wahlin Date: Mon, 3 Jul 2017 15:33:36 -0400 Subject: SERVER-29371 DocumentSource classes should provide auth requirements --- src/mongo/shell/explainable.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/mongo/shell/explainable.js') 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}; -- cgit v1.2.1