From aa7da1538de58ab6262a06c12d6625ada07e72e1 Mon Sep 17 00:00:00 2001 From: Dan Aprahamian Date: Fri, 10 Nov 2017 16:23:06 -0500 Subject: [PATCH] feat(aggregate): support hit field for aggregate command Supports passing an index hint to the aggregate command --- lib/collection.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/collection.js b/lib/collection.js index a4bff43d74..3ef3897551 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -2460,6 +2460,7 @@ Collection.prototype.aggregate = function(pipeline, options, callback) { opts.cursor || opts.out || opts.maxTimeMS || + opts.hint || opts.allowDiskUse) ? args.pop() : {}; @@ -2504,6 +2505,9 @@ Collection.prototype.aggregate = function(pipeline, options, callback) { if (options.allowDiskUse) command.allowDiskUse = options.allowDiskUse; if (typeof options.maxTimeMS === 'number') command.maxTimeMS = options.maxTimeMS; + // If we are giving a hint + if (options.hint) command.hint = options.hint; + options = shallowClone(options); // Ensure we have the right read preference inheritance options = getReadPreference(this, options, this.s.db, this);