-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
missing docs for setting the readPreference option in a query #5515
Comments
The only way to change the readPreference so far is by using a beforeFind trigger, like in the example below:
Note that in this example all queries in MyClass will be changed to the SECONDARY, but you can also do some verifications in the req object in order to check for a specific set of queries and only change for them. I will open a PR soon in the docs repo explaining this. |
That's odd. Reading the sources, I would think I can do it directly in a Query Line 112 in 3608b19
and MongoStorageAdapter seems to retrieve it from the Query, next to limit, skip, ...
What do you think ? |
@oallouch Good catch surprised |
I can try, but it'll be my first. I might need some help. npm WARN tar ENOENT: no such file or directory, open 'C:\Users\xxx\Documents\GitHub\Parse-SDK-JS\node_modules.staging\insert-module-globals-cbc4cf8a\test\global\filename.js' |
Which node version are you running and do you have permissions? |
@dplewis @oallouch when I wrote the readPreference option, my original idea was to include it as an option in the API and also in the JavaScript SDK, but, in that point in time, there was a discussion among some of the maintainers and they thought it was not a good idea to allow the client to choose where the query should run (it is a backend responsibility). I agree with the argument but I still think it would be much easier to have this option in the API. We can also protect it with master key so it could be set only in cloud code and server environments. So I see we have three options:
What do you think? @acinader can you please also share your thoughts on this? |
I've just remembered we actually wrote the PR with the API option for readPreference but it was never approved: I think it is a good start point for a new PR on this. |
The second one is very fine with me. |
@davimacedo I think you should write the server and client PRs. All the options (readPreference, includedReadPreference and subqueryReadPreference ) aren't as clear for me as it must be for you. Btw, when a readPreference is set for a query, shouldn't it also change the default values of includedReadPreference and subqueryReadPreference ? @dplewis my problem was just a config issue |
@dplewis I'm trying to write a Query.setReadPreference() test in the JS SDK, but I can't find an example of test that uses the output REST call generated from a Query. |
Ok, I'll just look at the output of ParseQuery.toJSON() . |
It would be easier to wait for something like #3963 to be implemented. That PR needs rebasing. @davimacedo Would you like to take a crack at it again? |
Yes, that would be good. I tried to modify the server myself. |
Never mind, I did |
The API changes were merged. I will now work on JS SDK. |
For the sake of clarity the API changes were made in #3963, @davimacedo I believe changes to the JS SDK are still to be done? - maybe a separate issue should be opened there and this one be closed? |
@TomWFox we still need to add the read preference option in the JS SDK and updated the docs. I will work this Tuesday to close the issue. |
Hi,
Like in my previous issue (where I said I can't find user.getSessionToken() in the docs), I face another documentation problem : this time I'd like to make some queries read from the secondary mongodb server, but I can't find the readPreference in the reference js documentation.
Thx a lot in advance,
Olivier
The text was updated successfully, but these errors were encountered: