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() {
3030 console . log ( "No documents found!" ) ;
3131 }
3232
33+ // replace console.dir with your callback to access individual elements
3334 await cursor . forEach ( console . dir ) ;
3435 } finally {
3536 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
2929cursors internally, and return the results of the operations instead of
3030a cursor.
3131
32+ .. _cursor-methods:
33+
3234Cursor Paradigms
3335----------------
3436
@@ -57,7 +59,7 @@ pulling all matching documents into a collection in process memory.
5759 When you reach the last result through iteration or through an at-once
5860 fetch, the cursor is exhausted which means it ceases to respond to methods
5961 that access the results.
60-
62+
6163For Each Functional Iteration
6264~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6365
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
2222information on the parameters you can pass to the method.
2323
2424The ``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.
3033
3134Example
3235-------
You can’t perform that action at this time.
0 commit comments