diff --git a/lib/collection.js b/lib/collection.js index a4bff43d74..8f1097d0b1 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -1608,7 +1608,9 @@ define.classMethod('createIndex', { callback: true, promise: true }); */ Collection.prototype.createIndexes = function(indexSpecs, options, callback) { if (typeof options === 'function') (callback = options), (options = {}); - options = options || {}; + + options = options ? shallowClone(options) : {}; + if (typeof options.maxTimeMS !== 'number') delete options.maxTimeMS; return executeOperation(this.s.topology, createIndexes, [this, indexSpecs, options, callback]); }; @@ -1659,6 +1661,7 @@ define.classMethod('createIndexes', { callback: true, promise: true }); * @param {number} [options.wtimeout=null] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {ClientSession} [options.session] optional session to use for this operation + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ @@ -1695,12 +1698,15 @@ define.classMethod('dropIndex', { callback: true, promise: true }); * @method * @param {Object} [options] Optional settings * @param {ClientSession} [options.session] optional session to use for this operation + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.dropIndexes = function(options, callback) { if (typeof options === 'function') (callback = options), (options = {}); - options = options || {}; + options = options ? shallowClone(options) : {}; + + if (typeof options.maxTimeMS !== 'number') delete options.maxTimeMS; return executeOperation(this.s.topology, dropIndexes, [this, options, callback]); };