@@ -24,10 +24,10 @@ The following functions directly return cursors:
24
24
25
25
- ``Db.listCollections()``
26
26
27
- Other methods, like :doc:`Collection.findOne()
28
- </usage-examples/findOne>` and `` Collection.watch()``,
29
- use cursors to return results but do not directly expose those
30
- cursors to the method caller .
27
+ Other methods such as :doc:`Collection.findOne() </usage-examples/findOne>`
28
+ and :doc:` Collection.watch() </fundamentals/crud#watch-subscribe>` use
29
+ cursors internally, and return the results of the operations instead of
30
+ a cursor .
31
31
32
32
Cursor Paradigms
33
33
----------------
@@ -52,6 +52,12 @@ pulling all matching documents into a collection in process memory.
52
52
undefined behaviour. Always wait for the previous
53
53
asynchronous operation to complete before running another.
54
54
55
+ .. note::
56
+
57
+ When you reach the last result through iteration or through an at-once
58
+ fetch, the cursor is exhausted which means it ceases to respond to methods
59
+ that access the results.
60
+
55
61
For Each Functional Iteration
56
62
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57
63
@@ -95,8 +101,9 @@ method to retrieve the subsequent element of the cursor:
95
101
Stream API
96
102
~~~~~~~~~~
97
103
98
- All cursors are Node Readable Streams operating in Object Mode. Cursors
99
- will work with most Node stream APIs:
104
+ All cursors are Node Readable Streams that operate in **Object Mode** which
105
+ passes JavaScript objects rather than Buffers or Strings through the
106
+ pipeline. Cursors work with most Node stream APIs:
100
107
101
108
.. literalinclude:: /code-snippets/crud/cursor.js
102
109
:language: javascript
@@ -131,6 +138,7 @@ exceeding memory constraints.
131
138
:end-before: end fetchAll cursor example
132
139
:dedent: 4
133
140
141
+
134
142
Cursor Utility Methods
135
143
----------------------
136
144
0 commit comments