Mongo query timeout in Mongoid

634 Views Asked by At

How do I set timeouts for my Mongo queries in Mongoid? I know Mongo supports cursor.maxTimeMS() but could not find it in Mongoid documentation.

1

There are 1 best solutions below

0
On

As of Mongoid 6, you can use something like this:

Model.max_time_ms(5000).all