Skip to content

Commit

Permalink
refactor: resolveReadPreference always returns a ReadPreference
Browse files Browse the repository at this point in the history
We use this method to optionally accept operation-level read
preference overrides, but we were just accepting those methods
passing in a string. This lets us ensure that we are _always_
dealing with a proper `ReadPreference` instance.
  • Loading branch information
mbroadst authored and daprahamian committed Aug 13, 2019
1 parent fca4084 commit 0d738f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ function resolveReadPreference(parent, options) {
throw new Error('No readPreference was provided or inherited.');
}

return readPreference;
return typeof readPreference === 'string' ? new ReadPreference(readPreference) : readPreference;
}

/**
Expand Down

0 comments on commit 0d738f5

Please sign in to comment.