File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
code-snippets/usage-examples
fundamentals/crud/read-operations Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ async function run() {
30
30
console . log ( "No documents found!" ) ;
31
31
}
32
32
33
+ // replace console.dir with your callback to access individual elements
33
34
await cursor . forEach ( console . dir ) ;
34
35
} finally {
35
36
await client . close ( ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ and :doc:`Collection.watch() </usage-examples/changeStream>` use
29
29
cursors internally, and return the results of the operations instead of
30
30
a cursor.
31
31
32
+ .. _cursor-methods:
33
+
32
34
Cursor Paradigms
33
35
----------------
34
36
@@ -57,7 +59,7 @@ pulling all matching documents into a collection in process memory.
57
59
When you reach the last result through iteration or through an at-once
58
60
fetch, the cursor is exhausted which means it ceases to respond to methods
59
61
that access the results.
60
-
62
+
61
63
For Each Functional Iteration
62
64
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63
65
Original file line number Diff line number Diff line change @@ -22,11 +22,14 @@ objects. See :node-api:`collection.find() <Collection.html#find>` for more
22
22
information on the parameters you can pass to the method.
23
23
24
24
The ``find()`` method returns a :node-api:`Cursor <Cursor.html>` that
25
- manages the results of your query. Iterate through the
26
- :doc:`cursor </fundamentals/crud/read-operations/cursor>` using cursor
27
- methods like ``next()``, ``toArray()``, or ``forEach()`` to
28
- fetch and work with the returned documents. If no documents match the
29
- query, ``find()`` returns an empty cursor.
25
+ manages the results of your query. You can iterate through the matching
26
+ documents using one of the following :ref:`cursor methods <cursor-methods>`:
27
+
28
+ - ``next()``
29
+ - ``toArray()``
30
+ - ``forEach()``
31
+
32
+ If no documents match the query, ``find()`` returns an empty cursor.
30
33
31
34
Example
32
35
-------
You can’t perform that action at this time.
0 commit comments