4
4
Find Documents
5
5
==============
6
6
7
+ .. facet::
8
+ :name: genre
9
+ :values: reference
10
+
11
+ .. meta::
12
+ :keywords: find, findOne, findMany, get, lookup
13
+ :description: Learn about how to retrieve data in the {+driver-long+}.
14
+
7
15
.. contents:: On this page
8
16
:local:
9
17
:backlinks: none
@@ -80,8 +88,27 @@ The following shows the output of the preceding query:
80
88
After the owner runs this query, they find two orders that matched the
81
89
criteria.
82
90
83
- For a runnable ``find()`` example, see our :ref:`Find Multiple
84
- Documents <retrieve-find>` page.
91
+ Find Example: Full File
92
+ ~~~~~~~~~~~~~~~~~~~~~~~
93
+
94
+ The following code is a complete, standalone file that performs a find one
95
+ operation and a find many operation.
96
+
97
+ .. include:: /includes/crud/example-intro.rst
98
+
99
+ .. io-code-block::
100
+
101
+ .. input:: /includes/crud/Find.java
102
+ :language: java
103
+ :dedent:
104
+
105
+ .. output::
106
+ :language: none
107
+ :visible: false
108
+
109
+ Number of documents found with find(): 101
110
+
111
+ Document found with find().first(){"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
85
112
86
113
.. _retrieve-aggregate:
87
114
@@ -97,7 +124,8 @@ instance of a ``MongoCollection``. This method accepts aggregation
97
124
expressions to run in sequence. To perform aggregations, you can
98
125
define aggregation stages that specify how to match documents, rename
99
126
fields, and group values. For more information, see our
100
- :ref:`Aggregation <java-aggregation>` guide.
127
+ :ref:`Aggregation <java-aggregation>` guide and the :ref:`Aggregation Expression
128
+ Operations <java-aggregation-expression-operations>` page.
101
129
102
130
Example
103
131
~~~~~~~
@@ -132,8 +160,21 @@ purchased color.
132
160
For more information about how to construct an aggregation pipeline, see
133
161
the {+mdb-server+} manual page on :manual:`Aggregation </aggregation>`.
134
162
135
- For additional information on the methods mentioned on this page, see
136
- the following API Documentation:
163
+ API Documentation
164
+ -----------------
165
+
166
+ For additional information on the methods and classes used to retrieve documents
167
+ on this page, see the following API Documentation:
168
+
169
+ - `find() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#find()>`__
170
+ - `first() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoIterable.html#first()>`__
171
+ - `FindIterable <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/FindIterable.html>`__
172
+ - `aggregate() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`__
173
+
174
+ Server Manual Entries
175
+ ---------------------
137
176
138
- - `MongoCollection.find() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#find()>`__
139
- - `MongoCollection.aggregate() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`__
177
+ - :manual:`Collections </core/databases-and-collections/#collections>`
178
+ - :manual:`Query Documents </tutorial/query-documents>`
179
+ - :manual:`Aggregation </aggregation>`
180
+ - :manual:`Aggregation stages </meta/aggregation-quick-reference/#stages>`
0 commit comments