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

How to set timeout #136

Open
simc opened this issue Aug 22, 2018 · 5 comments
Open

How to set timeout #136

simc opened this issue Aug 22, 2018 · 5 comments

Comments

@simc
Copy link

simc commented Aug 22, 2018

Hi,

How can I set a timeout for opening a connection and querying data?

Thanks

@matisiekpl
Copy link

Yup, it will be very helpful feature

@giorgiofran
Copy link
Contributor

On crud operations you have to use the "modern" methods.
For setting a timeout of 5000 MS on a find operation you could do:

 var res = await collection.modernFind(filter: {
    'rating': {r'$gt': 60}
  }, sort: {
    'state': 1,
    'name': 1
  }, findOptions: FindOptions(maxTimeMS: 5000)).toList();

@natgross
Copy link

natgross commented Feb 9, 2022

Can we set a timeout on the open() command?

@stMerlHin
Copy link

stMerlHin commented May 4, 2023

On crud operations you have to use the "modern" methods. For setting a timeout of 5000 MS on a find operation you could do:

 var res = await collection.modernFind(filter: {
    'rating': {r'$gt': 60}
  }, sort: {
    'state': 1,
    'name': 1
  }, findOptions: FindOptions(maxTimeMS: 5000)).toList();

Is there any way to do the same with an insert or delete ?

@cjcj125125
Copy link

How do I set the timeout period when I connect to db

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

6 participants