On this page本页内容
cursor.tailable()
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.
Marks the cursor as tailable.将游标标记为可剪裁。
For use against a capped collection only. 仅用于封顶集合。Using 对非封顶集合使用tailable()
against a non-capped collection will return an error.tailable()
将返回错误。
cursor.tailable()
uses the following syntax:使用以下语法:
cursor.tailable( { awaitData : <boolean> } )
tailable()
has the following parameter:具有以下参数:
awaitData | boolean |
|
tailable() is attached to.tailable() 附加到的游标。 |
A tailable cursor performs a collection scan over a capped collection. 一个可剪裁的游标在一个封顶集合上执行集合扫描。It remains open even after reaching the end of the collection. 即使在集合结束后,它仍保持打开状态。Applications can continue to iterate the tailable cursor as new data is inserted into the collection.当新数据插入集合时,应用程序可以继续迭代可剪裁游标。
If 如果awaitData
is set to true
, when the cursor reaches the end of the capped collection, MongoDB blocks the query thread for a period of time waiting for new data to arrive. awaitData
设置为true
,当游标到达封顶集合的末尾时,MongoDB会阻塞查询线程一段时间,等待新数据到达。When new data is inserted into the capped collection, the blocked thread is signaled to wake up and return the next batch to the client.当新数据插入到capped集合中时,阻塞的线程将被通知唤醒,并将下一批数据返回给客户端。
See Tailable Cursors.请参见可剪裁游标。