- Reference >
mongoshMethods >- Cursor Methods >
- cursor.maxAwaitTimeMS()
cursor.maxAwaitTimeMS()¶
On this page
Definition¶
-
cursor.maxAwaitTimeMS(<time limit>)¶ Important
mongoshMethodThis page documents a
mongoshmethod. This is not the documentation for a language-specific driver such as Node.js.For MongoDB API drivers, refer to the language-specific :driver:`MongoDB driver documentation </>`.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:Specifies the maximum time for the server to wait for new documents that match a tailable cursor query on a capped collection. For more information on iterating a cursor returned by a query, see: Iterate a Cursor in mongosh.
The
maxAwaitTimeMS()method has the following prototype form:The
maxAwaitTimeMS()method has the following parameter:Parameter Type Description millisecondsinteger Specifies a maximum wait time for new documents.
Important
This method, maxAwaitTimeMS(), sets a limit on how
long a tailable cursor waits
for the next response. maxTimeMS() sets a limit on
total processing time.
Example¶
Query the capped sales collection
to find agent Mary Kay’s weekly sales totals:
The highlighted line creates a tailable cursor on the sales collection. The
maxAwaitTimeMS() sets a one second maximum wait time
for the next cursor update.