From 8d424e5e7427a539b12031fad525c54cc0c31ef8 Mon Sep 17 00:00:00 2001 From: Hana Pearlman Date: Thu, 19 Nov 2020 16:21:24 -0500 Subject: [PATCH] list valid verbosity strings in param types --- lib/aggregation_cursor.js | 2 +- lib/collection.js | 24 ++++++++++++------------ lib/cursor.js | 2 +- lib/db.js | 2 +- lib/explain.js | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/aggregation_cursor.js b/lib/aggregation_cursor.js index 128b71001e0..a3afbcc460a 100644 --- a/lib/aggregation_cursor.js +++ b/lib/aggregation_cursor.js @@ -328,7 +328,7 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray; * ignores the verbosity parameter and executes in "queryPlanner". * * @method AggregationCursor.prototype.explain - * @param {string|boolean=true} verbosity - An optional mode in which to run the explain. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [verbosity=true] - An optional mode in which to run the explain. * @param {AggregationCursor~resultCallback} [callback] The result callback. * @return {Promise} returns Promise if no callback passed */ diff --git a/lib/collection.js b/lib/collection.js index 53bc3f3256b..df2645fa432 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -309,7 +309,7 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot', 'oplogReplay'] * @param {boolean} [options.noCursorTimeout] The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that. * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). * @param {boolean} [options.allowDiskUse] Enables writing to temporary files on the server. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @throws {MongoError} * @return {Cursor} @@ -739,7 +739,7 @@ Collection.prototype.insert = deprecate(function(docs, options, callback) { * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~updateWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed @@ -815,7 +815,7 @@ Collection.prototype.replaceOne = function(filter, doc, options, callback) { * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~updateWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed @@ -905,7 +905,7 @@ Collection.prototype.update = deprecate(function(selector, update, options, call * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {string|object} [options.hint] optional index hint for optimizing the filter query * @param {Collection~deleteWriteOpCallback} [callback] The command result callback @@ -940,7 +940,7 @@ Collection.prototype.removeOne = Collection.prototype.deleteOne; * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {string|object} [options.hint] optional index hint for optimizing the filter query * @param {Collection~deleteWriteOpCallback} [callback] The command result callback @@ -1066,7 +1066,7 @@ Collection.prototype.save = deprecate(function(doc, options, callback) { * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query. * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed @@ -1584,7 +1584,7 @@ Collection.prototype.countDocuments = function(query, options, callback) { * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query. * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed @@ -1664,7 +1664,7 @@ Collection.prototype.stats = function(options, callback) { * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed @@ -1698,7 +1698,7 @@ Collection.prototype.findOneAndDelete = function(filter, options, callback) { * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed @@ -1733,7 +1733,7 @@ Collection.prototype.findOneAndReplace = function(filter, replacement, options, * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] An ptional session to use for this operation * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed @@ -1850,7 +1850,7 @@ Collection.prototype.findAndRemove = deprecate(function(query, sort, options, ca * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. * @param {string} [options.comment] Add a comment to an aggregation command * @param {string|object} [options.hint] Add an index selection hint to an aggregation command - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~aggregationCallback} callback The command result callback * @return {(null|AggregationCursor)} @@ -2097,7 +2097,7 @@ Collection.prototype.group = deprecate(function( * @param {boolean} [options.jsMode=false] It is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X. * @param {boolean} [options.verbose=false] Provide statistics on job execution time. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @throws {MongoError} diff --git a/lib/cursor.js b/lib/cursor.js index 98480f0249d..5c17f43d788 100644 --- a/lib/cursor.js +++ b/lib/cursor.js @@ -1007,7 +1007,7 @@ class Cursor extends CoreCursor { * ignores the verbosity parameter and executes in "queryPlanner". * * @method - * @param {string|boolean=true} verbosity - An optional mode in which to run the explain. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [verbosity=true] - An optional mode in which to run the explain. * @param {Cursor~resultCallback} [callback] The result callback. * @return {Promise} returns Promise if no callback passed */ diff --git a/lib/db.js b/lib/db.js index 3889967f85a..344187d5cdc 100644 --- a/lib/db.js +++ b/lib/db.js @@ -312,7 +312,7 @@ Db.prototype.command = function(command, options, callback) { * @param {number} [options.batchSize=1000] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. * @param {object} [options.cursor] Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor. * @param {number} [options.cursor.batchSize=1000] Deprecated. Use `options.batchSize` - * @param {string|boolean} [options.explain] The verbosity mode for the explain output. + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output. * @param {boolean} [options.allowDiskUse=false] allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >). * @param {number} [options.maxTimeMS] maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. diff --git a/lib/explain.js b/lib/explain.js index 60f5b8f2e06..14ec6f438ae 100644 --- a/lib/explain.js +++ b/lib/explain.js @@ -11,7 +11,7 @@ const ExplainVerbosity = { /** * @class - * @property {string} verbosity The verbosity mode for the explain output + * @property {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'} verbosity The verbosity mode for the explain output. */ class Explain { /** @@ -21,7 +21,7 @@ class Explain { * and false as "queryPlanner". Prior to server version 3.6, aggregate() * ignores the verbosity parameter and executes in "queryPlanner". * - * @param {string|boolean} [verbosity] The verbosity mode for the explain output ({'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean}) + * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [verbosity] The verbosity mode for the explain output. */ constructor(verbosity) { if (typeof verbosity === 'boolean') {