cursor.isExhausted()
On this page本页内容
cursor.isExhausted()- Important
mongosh Method
This 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 MongoDB driver documentation.
Returns:返回值:Boolean 如果文档保留在游标读取的当前文档批中,则cursor.isExhausted()returnsfalseif documents remain in the current document batch read by the cursor. Otherwise, returnstrue.cursor.isExhausted()返回false。否则,返回true。
Behavior行为
Tailable Cursors可尾随游标
You can use 您可以将isExhausted() with a tailable cursor. A tailable cursor stays open even if no documents remain in the current batch. Other cursors are automatically closed when no documents remain.isExhausted()与可裁剪的游标一起使用。即使当前批处理中没有文档,可裁剪游标也会保持打开状态。当没有文档保留时,其他游标会自动关闭。
Change Streams更改流
You cannot use 不能将isExhausted() with change streams. Instead, to examine if:isExhausted()与更改流一起使用。相反,检查是否:
documents remain in a change stream cursor, use文档保留在更改流游标中,请使用cursor.tryNext().cursor.tryNext()。a change stream cursor is closed, use如果更改流游标已关闭,请使用cursor.isClosed().cursor.isClosed()。
For change stream examples, see Watch Example and Change Stream Images Example.有关更改流示例,请参阅观察示例和更改流图像示例。
Examples实例
This section contains examples that use a cursor to read documents from a collection with temperature readings from a weather sensor. You'll see examples of 本节包含使用游标从具有天气传感器温度读数的集合中读取文档的示例。您将看到isExhausted().isExhausted()的示例。