Skip to content

Commit 35bd9ae

Browse files
author
Chris Cho
authored
DOCSP-10371: address feedback on findOne usage example (#102)
1 parent 0d3da82 commit 35bd9ae

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

source/usage-examples/findOne.txt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Find a Document
66

77
.. note::
88
If you specify a callback method, ``findOne()`` returns nothing. If you do
9-
not specify one, this method returns a
10-
:mdn:`Promise <Web/JavaScript/Reference/Global_Objects/Promise>` that
11-
resolves to the result object when it completes. For more information on
12-
the result object type, see the
13-
:node-api:`API documentation <Collection.html#~resultCallback>`.
14-
15-
You can query for a single document in a collection with
16-
the ``collection.findOne()`` method. The ``findOne()`` method uses a query
9+
not specify one, this method returns a ``Promise`` that resolves to the
10+
result object when it completes. See our guide on :doc:`Promises and
11+
Callbacks </fundamentals/promises>` for more information, or the
12+
:node-api:`API documentation <Collection.html#~resultCallback>` for
13+
information on the result object.
14+
15+
You can query for a single document in a collection with the
16+
``collection.findOne()`` method. The ``findOne()`` method uses a query
1717
document that you provide to match only the subset of the documents in the
18-
collection that match the query. If you don't provide a query document (or if
19-
you provide an empty document), MongoDB matches all documents in the
20-
collection. However, the operation only returns the first matched document.
21-
For more information on querying MongoDB, see our
18+
collection that match the query. If you don't provide a query document or if
19+
you provide an empty document, MongoDB matches all documents in the
20+
collection. The ``findOne()`` operation only returns the first matched
21+
document. For more information on querying MongoDB, see our
2222
:doc:`documentation on query documents </fundamentals/crud/query-document>`.
2323

2424
You can also define additional query options such as
@@ -33,7 +33,7 @@ Example
3333
-------
3434

3535
The following snippet finds a single document from the ``movies``
36-
collection. It uses the following:
36+
collection. It uses the following parameters:
3737

3838
- A **query document** that configures the query to return only
3939
movies with the title of exactly the text ``'The Room'``.
@@ -50,5 +50,12 @@ collection. It uses the following:
5050

5151
.. literalinclude:: /code-snippets/usage-examples/findOne.js
5252
:language: javascript
53-
:emphasize-lines: 26
54-
:linenos:
53+
:dedent: 4
54+
55+
If you run the example above, you should see a result that resembles the
56+
following:
57+
58+
.. code-block:: javascript
59+
60+
{ title: 'The Room', imdb: { rating: 3.5, votes: 25673, id: 368226 } }
61+

0 commit comments

Comments
 (0)