Skip to content

Commit a649e35

Browse files
committed
fix(collection): depend on resolveReadPreference for inheritance
We no longer need to explicitly copy `readPreference` from the parent `Collection` here, because we already handle inheritance in `resolveReadPreference`.
1 parent df43f11 commit a649e35

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/collection.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const updateOne = require('./operations/collection_ops').updateOne;
8484
* });
8585
*/
8686

87-
const mergeKeys = ['readPreference', 'ignoreUndefined'];
87+
const mergeKeys = ['ignoreUndefined'];
8888

8989
/**
9090
* Create a new Collection instance (INTERNAL TYPE, do not instantiate directly)
@@ -322,7 +322,8 @@ Collection.prototype.find = function(query, options, callback) {
322322
: { _id: 1 };
323323
}
324324

325-
let newOptions = {};
325+
// Make a shallow copy of options
326+
let newOptions = Object.assign({}, options);
326327

327328
// Make a shallow copy of the collection options
328329
for (let key in this.s.options) {
@@ -331,11 +332,6 @@ Collection.prototype.find = function(query, options, callback) {
331332
}
332333
}
333334

334-
// Make a shallow copy of options
335-
for (let optKey in options) {
336-
newOptions[optKey] = options[optKey];
337-
}
338-
339335
// Unpack options
340336
newOptions.skip = options.skip ? options.skip : 0;
341337
newOptions.limit = options.limit ? options.limit : 0;

0 commit comments

Comments
 (0)