Skip to content

Commit 377cca0

Browse files
authored
DOCSP 28579 restructuring project page (#7013)
* DOCSP-28579 clarifying project limitations * DOCSP-28579 clarifying project limitations * DOCSP-28579 tech edit
1 parent 5c19c1e commit 377cca0

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
You cannot use an array index with the :pipeline:`$project` stage.
2-
See :ref:`example-project-array-indexes`.
2+
For more information, see :ref:`example-project-array-indexes`.

source/reference/operator/aggregation/project.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ The :pipeline:`$project` specifications have the following forms:
8686

8787
See also the :pipeline:`$unset` stage to exclude fields.
8888

89-
Considerations
90-
--------------
89+
Behavior
90+
--------
9191

92-
Include Existing Fields
93-
~~~~~~~~~~~~~~~~~~~~~~~
92+
Include Fields
93+
~~~~~~~~~~~~~~
9494

9595
- The ``_id`` field is, by default, included in the output documents.
9696
To include any other fields from the input documents in the output
@@ -101,8 +101,8 @@ Include Existing Fields
101101
document, :pipeline:`$project` ignores that field inclusion and
102102
does not add the field to the document.
103103

104-
Suppress the ``_id`` Field
105-
~~~~~~~~~~~~~~~~~~~~~~~~~~
104+
``_id`` Field
105+
~~~~~~~~~~~~~
106106

107107
By default, the ``_id`` field is included in the output documents.
108108
To exclude the ``_id`` field from the output documents, you
@@ -226,11 +226,25 @@ fails with the same error:
226226

227227
.. include:: /includes/aggregation/fact-project-stage-placement.rst
228228

229-
Restrictions
230-
~~~~~~~~~~~~
229+
Considerations
230+
--------------
231+
232+
Empty Specification
233+
~~~~~~~~~~~~~~~~~~~
234+
235+
MongoDB returns an error if the :pipeline:`$project` stage is passed an
236+
empty document.
237+
238+
For example, running the following pipeline produces an error:
239+
240+
.. code-block:: javascript
241+
242+
db.myCollection.aggregate( [ {
243+
$project: { }
244+
} ] )
231245

232-
An error is returned if the :pipeline:`$project` specification is
233-
an empty document.
246+
Array Index
247+
~~~~~~~~~~~
234248

235249
.. include:: /includes/project-stage-and-array-index.rst
236250

0 commit comments

Comments
 (0)