Skip to content

Commit

Permalink
feat(maxTimeMS): adding maxTimeMS option to createIndexes and dropInd…
Browse files Browse the repository at this point in the history
…exes
  • Loading branch information
daprahamian committed Nov 12, 2017
1 parent b975df1 commit 90d4a63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
};
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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]);
};
Expand Down

0 comments on commit 90d4a63

Please sign in to comment.