Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readPreference is respected on GridFSBucket.find() #1850

Closed
wants to merge 2 commits into from
Closed

readPreference is respected on GridFSBucket.find() #1850

wants to merge 2 commits into from

Conversation

adityapatadia
Copy link
Contributor

@adityapatadia adityapatadia commented Oct 10, 2018

Currently, there is no way to specify readPreference on GridFSBucket.find(). This change makes.find() use readPreference set on Bucket.

`.find()` now used readPreference set on Bucket.
@adityapatadia adityapatadia changed the title readPreference is respected on find readPreference is respected on GridFSBucket.find() Oct 10, 2018
Copy link
Member

@mbroadst mbroadst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I have a suggestion on how to improve this

@@ -213,6 +213,10 @@ GridFSBucket.prototype.find = function(filter, options) {

var cursor = this.s._filesCollection.find(filter);

if (this.s.options.readPreference) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we support it at operation-level generally, I think a better approach might be:

const readPreference = resolveReadPreference(options, { default: this.s.options.readPreference });
if (readPreference) cursor.setReadPreference(readPreference);

Also, please document the option above!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is resolveReadPreference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a helper method we developed to handle type coercion and inheritance for read preferences, see here

@mbroadst
Copy link
Member

@adityapatadia ping on this? We can otherwise create a JIRA ticket to track the work and close this PR

@adityapatadia
Copy link
Contributor Author

adityapatadia commented Jul 24, 2020 via email

@agolin95
Copy link
Contributor

@agolin95 agolin95 added the tracked-in-jira Ticket filed in MongoDB's Jira system label Nov 16, 2020
@nbbeeken nbbeeken closed this Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked-in-jira Ticket filed in MongoDB's Jira system
Projects
None yet
4 participants