@@ -43,7 +43,8 @@ Select All Documents in a Collection
43
43
44
44
.. include:: /includes/driver-examples/driver-example-query-7.rst
45
45
46
- This operation corresponds to the following SQL statement:
46
+ This operation uses a filter predicate of ``{}``, which corresponds to
47
+ the following SQL statement:
47
48
48
49
.. code-block:: sql
49
50
@@ -80,7 +81,8 @@ This operation corresponds to the following SQL statement:
80
81
81
82
- id: nodejs
82
83
content: |
83
- For more information on the syntax of the method, see
84
+
85
+ To see supported options for the ``find()`` method, see
84
86
:node-api:`find() <Collection.html#find>`.
85
87
86
88
- id: php
@@ -120,7 +122,8 @@ documents where the ``status`` equals ``"D"``:
120
122
121
123
.. include:: /includes/driver-examples/driver-example-query-9.rst
122
124
123
- This operation corresponds to the following SQL statement:
125
+ This operation uses a filter predicate of ``{ status: "D" }``, which
126
+ corresponds to the following SQL statement:
124
127
125
128
.. code-block:: sql
126
129
@@ -153,7 +156,9 @@ collection where ``status`` equals either ``"A"`` or ``"D"``:
153
156
use the :query:`$in` operator rather than the :query:`$or`
154
157
operator when performing equality checks on the same field.
155
158
156
- The operation corresponds to the following SQL statement:
159
+ The operation uses a filter predicate of
160
+ ``{ status: { $in: [ "A", "D" ] } }``, which corresponds to the
161
+ following SQL statement:
157
162
158
163
.. code-block:: sql
159
164
@@ -176,7 +181,9 @@ than (:query:`$lt`) ``30``:
176
181
177
182
.. include:: /includes/driver-examples/driver-example-query-11.rst
178
183
179
- The operation corresponds to the following SQL statement:
184
+ The operation uses a filter predicate of
185
+ ``{ status: "A", qty: { $lt: 30 } }``, which corresponds to the
186
+ following SQL statement:
180
187
181
188
.. code-block:: sql
182
189
@@ -199,18 +206,21 @@ the ``status`` equals ``"A"`` **or** ``qty`` is less than
199
206
200
207
.. include:: /includes/driver-examples/driver-example-query-12.rst
201
208
202
- The operation corresponds to the following SQL statement:
209
+ The operation uses a filter predicate of
210
+ ``{ $or: [ { status: 'A' }, { qty: { $lt: 30 } } ] }``, which
211
+ corresponds to the following SQL statement:
203
212
204
213
.. code-block:: sql
205
214
206
215
SELECT * FROM inventory WHERE status = "A" OR qty < 30
207
216
208
217
.. note::
209
- Queries which use :ref:`comparison operators <query-selectors-comparison>`
210
- are subject to :ref:`type-bracketing`.
218
+
219
+ Queries that use :ref:`comparison operators
220
+ <query-selectors-comparison>` are subject to :ref:`type-bracketing`.
211
221
212
222
Specify ``AND`` as well as ``OR`` Conditions
213
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
+ --------------------------------------------
214
224
215
225
In the following example, the compound query document selects all
216
226
documents in the collection where the ``status`` equals ``"A"``
@@ -219,7 +229,18 @@ documents in the collection where the ``status`` equals ``"A"``
219
229
220
230
.. include:: /includes/driver-examples/driver-example-query-13.rst
221
231
222
- The operation corresponds to the following SQL statement:
232
+ The operation uses a filter predicate of:
233
+
234
+ .. code-block:: javascript
235
+
236
+ {
237
+ status: 'A',
238
+ $or: [
239
+ { qty: { $lt: 30 } }, { item: { $regex: '^p' } }
240
+ ]
241
+ }
242
+
243
+ which corresponds to the following SQL statement:
223
244
224
245
.. code-block:: sql
225
246
@@ -349,6 +370,17 @@ For reads to :doc:`replica sets </replication>` and replica set
349
370
level of isolation for their reads. For more information, see
350
371
:doc:`/reference/read-concern`.
351
372
373
+ Query Result Format
374
+ ~~~~~~~~~~~~~~~~~~~
375
+
376
+ When you run a find operation with a MongoDB driver or ``mongosh``, the
377
+ command returns a :term:`cursor` that manages query results. The query
378
+ results are not returned as an array of documents.
379
+
380
+ To learn how to iterate through documents in a cursor, refer to your
381
+ :driver:`driver's documentation </>`. If you are using ``mongosh``, see
382
+ :ref:`read-operations-cursors`.
383
+
352
384
.. tabs-drivers::
353
385
354
386
tabs:
0 commit comments