Skip to content

Commit

Permalink
fix(collection): depend on resolveReadPreference for inheritance
Browse files Browse the repository at this point in the history
We no longer need to explicitly copy `readPreference` from the
parent `Collection` here, because we already handle inheritance
in `resolveReadPreference`.
  • Loading branch information
mbroadst committed Jun 19, 2018
1 parent df43f11 commit a649e35
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const updateOne = require('./operations/collection_ops').updateOne;
* });
*/

const mergeKeys = ['readPreference', 'ignoreUndefined'];
const mergeKeys = ['ignoreUndefined'];

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

let newOptions = {};
// Make a shallow copy of options
let newOptions = Object.assign({}, options);

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

// Make a shallow copy of options
for (let optKey in options) {
newOptions[optKey] = options[optKey];
}

// Unpack options
newOptions.skip = options.skip ? options.skip : 0;
newOptions.limit = options.limit ? options.limit : 0;
Expand Down

0 comments on commit a649e35

Please sign in to comment.