On this page本页内容
cursor.
tailable
()¶mongo
Shell Method
This page documents the 本页记录了mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo
shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
New in version 3.2.版本3.2中的新功能。
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:使用以下语法:
tailable()
has the following parameter:具有以下参数:
awaitData |
boolean |
|
Returns: | 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.当新数据被插入到封顶集合中时,阻塞的线程会收到唤醒信号,并将下一批数据返回给客户端。
See Tailable Cursors.请参见可裁剪游标。