You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/crud/query-documents/find.txt
+17-11Lines changed: 17 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Find Documents
15
15
.. contents:: On this page
16
16
:local:
17
17
:backlinks: none
18
-
:depth: 1
18
+
:depth: 2
19
19
:class: singlecol
20
20
21
21
Overview
@@ -61,7 +61,8 @@ specify a query, see our :ref:`Specify a Query
61
61
<java-query>` guide.
62
62
63
63
To retrieve a single document, you can append the ``first()`` method to your
64
-
``find()`` operation.
64
+
``find()`` operation. You can use the ``sort()`` operation before selecting the first
65
+
document to help choose the correct file.
65
66
66
67
Example
67
68
~~~~~~~
@@ -94,12 +95,14 @@ criteria.
94
95
Find Example: Full File
95
96
~~~~~~~~~~~~~~~~~~~~~~~
96
97
97
-
The following code is a complete, standalone file that performs a find
98
-
operation to retrieve multiple douments, and a find operation with the first
99
-
method to retrieve a single document.
100
-
101
98
.. include:: /includes/crud/example-intro.rst
102
99
100
+
The following code is a complete, standalone file that performs the following
101
+
actions:
102
+
103
+
- Calls the ``find()`` method to retrieve multiple documents that have a ``runtime`` value less than 15, applying a projection and sort to the results
104
+
- Calls the ``find()`` and ``first()`` method to retrieve a document that has a ``title`` value of ``"The Room"``, applying a projection and sort before returning the first match
105
+
103
106
.. io-code-block::
104
107
105
108
.. input:: /includes/crud/Find.java
@@ -112,7 +115,7 @@ method to retrieve a single document.
112
115
113
116
Number of documents found with find(): 101
114
117
115
-
Document found with find().first(){"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
118
+
Document found with find().first(): {"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
116
119
117
120
.. _retrieve-aggregate:
118
121
@@ -164,19 +167,22 @@ purchased color.
164
167
For more information about how to construct an aggregation pipeline, see
165
168
the {+mdb-server+} manual page on :manual:`Aggregation </aggregation>`.
166
169
170
+
Additional Information
171
+
----------------------
172
+
167
173
API Documentation
168
-
-----------------
174
+
~~~~~~~~~~~~~~~~~
169
175
170
-
For more information on the methods and classes used to retrieve documents
171
-
on this page, see the following API Documentation:
176
+
For more information about the methods and classes used to retrieve documents
177
+
on this page, see the following API cocumentation:
0 commit comments