44Retrieve Data
55=============
66
7+ .. facet::
8+ :name: genre
9+ :values: reference
10+
11+ .. meta::
12+ :keywords: node.js, code example, find one, find many
13+
714.. contents:: On this page
815 :local:
916 :backlinks: none
@@ -72,8 +79,8 @@ see the :ref:`node-fundamentals-query-document` guide.
7279
7380 .. code-block:: javascript
7481
75- await myColl.find(); // no query
76- await myColl.find({}); // empty query
82+ myColl.find(); // no query
83+ myColl.find({}); // empty query
7784
7885 If you don't pass a query or pass an empty query
7986 to the ``findOne()`` method, the operation returns a single
@@ -82,7 +89,7 @@ see the :ref:`node-fundamentals-query-document` guide.
8289 You can specify options in a find operation even when you pass an
8390 empty query. For example, the following code shows how you can
8491 specify a projection as an option while executing a find operation
85- with an empty query parameter:
92+ that receives an empty query parameter:
8693
8794 .. code-block:: javascript
8895
@@ -92,10 +99,13 @@ see the :ref:`node-fundamentals-query-document` guide.
9299
93100 const findResult = await myColl.findOne({}, options);
94101
95- If you resolve the ``Promise`` returned by ``find()``, you receive
96- a reference to a ``Cursor`` with which you can navigate matched documents.
97- If you resolve the ``Promise`` returned by ``findOne()``, you receive the
98- matching document or ``null`` if there are no matches.
102+ For more information about projecting document fields, see the
103+ :ref:`node-fundamentals-project` guide.
104+
105+ The ``find()`` method returns a ``Cursor`` instance from which you can
106+ access the matched documents. The ``findOne()`` method returns a ``Promise``
107+ instance, which you can resolve to access either the matching document or
108+ a ``null`` value if there are no matches.
99109
100110.. example::
101111
@@ -129,8 +139,20 @@ matching document or ``null`` if there are no matches.
129139 ...
130140 ]
131141
132- See the :ref:`find() <node-usage-find>` and :ref:`findOne()
133- <node-usage-findone>` for fully-runnable examples.
142+ Additional Information
143+ ~~~~~~~~~~~~~~~~~~~~~~
144+
145+ For runnable code examples that demonstrate find operations, see the following
146+ usage examples:
147+
148+ - :ref:`node-usage-findone`
149+ - :ref:`node-usage-find`
150+
151+ For more information about the ``findOne()`` and ``find()`` methods, see the
152+ following Server manual documentation:
153+
154+ - :manual:`findOne() </reference/method/db.collection.findOne/>`
155+ - :manual:`find() </reference/method/db.collection.find/>`
134156
135157Aggregate Data from Documents
136158-----------------------------
@@ -173,8 +195,12 @@ group, and arrange the result data from a collection.
173195 { _id: 'created', count: 9 }
174196 ]
175197
176- See the {+mdb-server+} manual pages on :manual:`aggregation </aggregation>`
177- for more information on how to construct an aggregation pipeline.
198+ Additional Information
199+ ~~~~~~~~~~~~~~~~~~~~~~
200+
201+ For more information on how to construct an aggregation pipeline, see
202+ the :ref:`node-aggregation` guide or :manual:`Aggregation Operations </aggregation>`
203+ in the Server manual.
178204
179205.. _node-fundamentals-watch:
180206
@@ -200,8 +226,11 @@ data whenever write operations are executed on the collection.
200226 :start-after: start watch crud example
201227 :end-before: end watch crud example
202228
203- For a runnable example of the ``watch()`` method using the NodeJS driver, see
204- the :ref:`change streams <node-usage-watch>` usage example.
229+ Additional Information
230+ ~~~~~~~~~~~~~~~~~~~~~~
231+
232+ For a runnable example of the ``watch()`` method, see the
233+ :ref:`Watch for Changes <node-usage-watch>` usage example.
205234
206235.. _node-retrieve-instruqt-lab:
207236
0 commit comments