Skip to content

Commit 17f066f

Browse files
author
Chris Cho
authored
DOCSP-14153: address feedback on find usage example (#138)
1 parent d1e7c84 commit 17f066f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

source/code-snippets/usage-examples/find.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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();

source/fundamentals/crud/read-operations/cursor.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ and :doc:`Collection.watch() </usage-examples/changeStream>` use
2929
cursors internally, and return the results of the operations instead of
3030
a cursor.
3131

32+
.. _cursor-methods:
33+
3234
Cursor 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+
6163
For Each Functional Iteration
6264
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6365

source/usage-examples/find.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ objects. See :node-api:`collection.find() <Collection.html#find>` for more
2222
information on the parameters you can pass to the method.
2323

2424
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.
3033

3134
Example
3235
-------

0 commit comments

Comments
 (0)