@@ -4,14 +4,42 @@ db.collection.findOne()
44
55.. default-domain:: mongodb
66
7- .. method:: db.collection.findOne(query)
7+ .. method:: db.collection.findOne(query,projection )
88
99 :param document query: Optional. A :term:`document` that specifies the :term:`query`
1010 using the JSON-like syntax and :doc:`query operators
1111 </reference/operators>`.
12+ :param document projection:
13+
14+ Optional. Controls the fields to return, or the
15+ :term:`projection`. The ``projection`` argument will
16+ resemble the following prototype:
17+
18+ .. code-block:: javascript
19+
20+ { field1: boolean, field2: boolean ... }
21+
22+ The ``boolean`` can take the following include or exclude
23+ values:
24+
25+ - ``1`` or ``true`` to include. The
26+ :method:`~db.collection.findOne()` method always includes
27+ the :term:`_id` field even if the field is not explicitly
28+ stated to return in the :term:`projection` parameter.
29+
30+ - ``0`` or ``false`` to exclude.
31+
32+ The ``projection`` cannot contain both include and exclude
33+ specifications except for the exclusion of the ``_id`` field.
34+
35+ Omit the ``projection`` parameter to return **all** the fields in
36+ the matching documents.
1237
1338 :returns: One document that satisfies the query specified as the
14- argument to this method.
39+ argument to this method. If the ``projection`` argument is
40+ specified, the returned document contains only the
41+ ``projection`` fields, and the ``_id`` field if you do not
42+ explicitly exclude the ``_id`` field.
1543
1644 Returns only one document that satisfies the specified query. If
1745 multiple documents satisfy the query, this method returns the first
0 commit comments