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

when l use find , how can l set readConcern("majority") #6777

Closed
cl1069573062 opened this issue Jul 27, 2018 · 2 comments
Closed

when l use find , how can l set readConcern("majority") #6777

cl1069573062 opened this issue Jul 27, 2018 · 2 comments
Milestone

Comments

@cl1069573062
Copy link

cl1069573062 commented Jul 27, 2018

on mongodb driver ,l can use find like this.

db.restaurants.find( { _id: 5 } ).readConcern("linearizable").maxTimeMS(10000)

how can l use readConcern on mongoose?

@Fonger
Copy link
Contributor

Fonger commented Jul 29, 2018

Test and it works.

Restaurant.find({ _id: 5 }).maxTime(10000).setOptions({ readConcern: { level: 'linearizable' } })

The readConcern options will pass down to node-mongodb-native and parsed there.

@Fonger
Copy link
Contributor

Fonger commented Jul 29, 2018

I have submitted a pull request to mquery to make readConcern and maxTimeMS work like in mongo shell

EDIT:
As of mongoose 5.2.6, you can use the following syntax now.
Restaurant.find( { _id: 5 } ).readConcern("linearizable").maxTimeMS(10000)

@vkarpov15 vkarpov15 added this to the 5.2.6 milestone Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants