7
7
Of the four basic database operations (i.e. CRUD), read operation are
8
8
those that retrieve records or or :term:`documents <document>` from a
9
9
:term:`collection` in MongoDB. For general information about read
10
- operations and the factors that affect their performanace , see
10
+ operations and the factors that affect their performance , see
11
11
:ref:`/core/read-operations`; for documentation of the other CRUD
12
12
operations, see the :doc:`/crud` page.
13
13
@@ -188,12 +188,14 @@ Consider the following examples that illustrate the use of the
188
188
} } } )
189
189
190
190
- If there is a ``<projection>`` argument, the :method:`find()
191
- <db.collection.find()>` method returns only those fields as
192
- specified in the projection to include or exclude:
191
+ <db.collection.find()>` method returns only those fields as specified
192
+ in the ``< projection>`` argument to include or exclude:
193
193
194
194
.. note:: The ``_id`` field is implicitly included in the
195
- projection, and in projections that explicitly include fields,
196
- ``_id`` is the only field that you can explicitly exclude.
195
+ ``<projection>`` argument. In projections that explicitly include
196
+ fields, ``_id`` is the only field that you can explicitly exclude.
197
+ Otherwise, you cannot mix include field and exclude field
198
+ specifications.
197
199
198
200
- The following operation finds all documents in the ``csbios``
199
201
collection and returns only the ``name`` field, the ``contribs``
@@ -211,11 +213,6 @@ Consider the following examples that illustrate the use of the
211
213
212
214
db.csbios.find( { }, { name: 1, contribs: 1, _id: 0 } )
213
215
214
- .. note::
215
-
216
- The ``projection`` argument cannot contain both include and
217
- exclude specifications *except* for the exclusion of the ``_id``.
218
-
219
216
- The following operation finds the documents in the ``csbios``
220
217
collection where the ``contribs`` field contains the element
221
218
``OOP`` and returns all fields *except* the ``_id`` field, the
@@ -285,7 +282,7 @@ Except for the return value, :method:`findOne()
285
282
examples that illustrate the use of the :method:`findOne()
286
283
<db.collection.findOne()>` method:
287
284
288
- - If there is no ``query`` argument, the :method:`findOne()
285
+ - If there is no ``< query> `` argument, the :method:`findOne()
289
286
<db.collection.findOne()>` method selects just one document from a
290
287
collection.
291
288
@@ -296,9 +293,9 @@ examples that illustrate the use of the :method:`findOne()
296
293
297
294
db.csbios.findOne()
298
295
299
- - If there is a ``query`` argument, the :method:`findOne()
296
+ - If there is a ``< query> `` argument, the :method:`findOne()
300
297
<db.collection.findOne()>` method selects the first document from a
301
- collection that meets the ``query`` argument:
298
+ collection that meets the ``< query> `` argument:
302
299
303
300
- The following operation returns the first matching document from
304
301
the ``csbios`` collection where either the field ``first`` in the
@@ -311,8 +308,9 @@ examples that illustrate the use of the :method:`findOne()
311
308
{ birth: { $lt: new Date('01/01/1945') } }
312
309
] } )
313
310
314
- - You can pass a projection to :method:`findOne()
315
- <db.collection.findOne()>` to control the fields included in the result set:
311
+ - You can pass a ``<projection>`` argument to :method:`findOne()
312
+ <db.collection.findOne()>` to control the fields included in the
313
+ result set:
316
314
317
315
- The following operation finds a document in the ``csbios``
318
316
collection and returns only the ``name`` field, the ``contribs``
0 commit comments