cursor.isExhausted()
cursor.isExhausted()
Important
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. For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.Returns: Boolean cursor.isExhausted()
returnsfalse
if documents remain in the current document batch read by the cursor. Otherwise, returnstrue
.
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.
Change Streams
You cannot use isExhausted()
with change streams. Instead, to examine if:
documents remain in a change stream cursor, use
cursor.tryNext()
.a change stream cursor is closed, use
cursor.isClosed()
.
For a change stream example, see Watch 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()
.