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/read-operations/retrieve.txt
+17-11Lines changed: 17 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Retrieve Data
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
@@ -63,7 +63,8 @@ specify a query, see our :doc:`Specify a Query
63
63
</crud/query-document>` guide.
64
64
65
65
To retrieve a single document, you can append the ``first()`` method to your
66
-
``find()`` operation.
66
+
``find()`` operation. You can use the ``sort()`` operation before selecting the first
67
+
document to help choose the correct file.
67
68
68
69
Example
69
70
~~~~~~~
@@ -96,12 +97,14 @@ criteria.
96
97
Find Example: Full File
97
98
~~~~~~~~~~~~~~~~~~~~~~~
98
99
99
-
The following code is a complete, standalone file that performs a find
100
-
operation to retrieve multiple douments, and a find operation with the first
101
-
method to retrieve a single document.
102
-
103
100
.. include:: /includes/crud/example-intro.rst
104
101
102
+
The following code is a complete, standalone file that performs the following
103
+
actions:
104
+
105
+
- Calls the ``find()`` method to retrieve multiple documents that have a ``runtime`` value less than 15, applying a projection and sort to the results
106
+
- 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
107
+
105
108
.. io-code-block::
106
109
107
110
.. input:: /includes/crud/Find.java
@@ -114,7 +117,7 @@ method to retrieve a single document.
114
117
115
118
Number of documents found with find(): 101
116
119
117
-
Document found with find().first(){"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
120
+
Document found with find().first(): {"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
118
121
119
122
.. _retrieve-aggregate:
120
123
@@ -166,19 +169,22 @@ purchased color.
166
169
For more information about how to construct an aggregation pipeline, see
167
170
the {+mdb-server+} manual page on :manual:`Aggregation </aggregation>`.
168
171
172
+
Additional Information
173
+
----------------------
174
+
169
175
API Documentation
170
-
-----------------
176
+
~~~~~~~~~~~~~~~~~
171
177
172
-
For more information on the methods and classes used to retrieve documents
173
-
on this page, see the following API Documentation:
178
+
For more information about the methods and classes used to retrieve documents
179
+
on this page, see the following API cocumentation:
0 commit comments