File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed
reference/operator/aggregation Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 1
1
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 `.
Original file line number Diff line number Diff line change @@ -86,11 +86,11 @@ The :pipeline:`$project` specifications have the following forms:
86
86
87
87
See also the :pipeline:`$unset` stage to exclude fields.
88
88
89
- Considerations
90
- --------------
89
+ Behavior
90
+ --------
91
91
92
- Include Existing Fields
93
- ~~~~~~~~~~~~~~~~~~~~~~~
92
+ Include Fields
93
+ ~~~~~~~~~~~~~~
94
94
95
95
- The ``_id`` field is, by default, included in the output documents.
96
96
To include any other fields from the input documents in the output
@@ -101,8 +101,8 @@ Include Existing Fields
101
101
document, :pipeline:`$project` ignores that field inclusion and
102
102
does not add the field to the document.
103
103
104
- Suppress the ``_id`` Field
105
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
104
+ ``_id`` Field
105
+ ~~~~~~~~~~~~~
106
106
107
107
By default, the ``_id`` field is included in the output documents.
108
108
To exclude the ``_id`` field from the output documents, you
@@ -226,11 +226,25 @@ fails with the same error:
226
226
227
227
.. include:: /includes/aggregation/fact-project-stage-placement.rst
228
228
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
+ } ] )
231
245
232
- An error is returned if the :pipeline:`$project` specification is
233
- an empty document.
246
+ Array Index
247
+ ~~~~~~~~~~~
234
248
235
249
.. include:: /includes/project-stage-and-array-index.rst
236
250
You can’t perform that action at this time.
0 commit comments