On this page本页内容
cursor.maxAwaitTimeMS(<time limit>)
This is a mongosh
method. This is not the documentation for Node.js
or other programming language specific driver methods.
In most cases, mongosh
methods work the same way as the legacy mongo
shell methods. However, some legacy methods are unavailable in mongosh
.
For the legacy mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release:
For MongoDB API drivers, refer to the language specific MongoDB driver documentation.有关MongoDB API驱动程序,请参阅特定语言的MongoDB驱动程序文档。
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
.mongosh
中迭代游标。
The maxAwaitTimeMS()
method has the following prototype form:maxAwaitTimeMS()
方法具有以下原型形式:
db.collection.find( { <query> }, { <projection> } ).tailable( { awaitData: true } ).maxAwaitTimeMS( <milliseconds> )
The maxAwaitTimeMS()
method has the following parameter:maxAwaitTimeMS()
方法具有以下参数:
milliseconds | integer |
This method, 此方法maxAwaitTimeMS()
, sets a limit on how long a tailable cursor waits for the next response. maxAwaitTimeMS()
对可跟踪游标等待下一个响应的时间设置限制。maxTimeMS()
sets a limit on total processing time.设置总处理时间的限制。
Query the capped 查询封顶sales
collection to find agent Mary Kay's weekly sales totals:sales
额集合以查找经纪人玛丽·凯的每周销售额总计:
db.sales.find( { agent: "Mary Kay" }, { _id: 0, agent: 1, weeklyTotal: 1 } ).tailable( { awaitData: true } ).maxAwaitTimeMS( 1000 )
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.maxAwaitTimeMS()
设置下一次游标更新的最长等待时间为1秒。