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
Conversation
`.find()` now used readPreference set on Bucket.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is resolveReadPreference
?
There was a problem hiding this comment.
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
@adityapatadia ping on this? We can otherwise create a JIRA ticket to track the work and close this PR |
I am not able to work on this and we have also stopped using GridFs.
You can handle this as you deem fit.
… On 21-Jul-2020, at 5:07 PM, Matt Broadstone ***@***.***> wrote:
@adityapatadia ping on this? We can otherwise create a JIRA ticket to track the work and close this PR
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Tracked by https://jira.mongodb.org/browse/NODE-2890 |
Currently, there is no way to specify readPreference on GridFSBucket.find(). This change makes
.find()
use readPreference set on Bucket.