File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
reference/operator/aggregation Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,8 @@ The :pipeline:`$lookup` takes a document with the following fields:
179
179
collection. To return all documents, specify an empty pipeline
180
180
``[]``.
181
181
182
+ The ``pipeline`` cannot include the :pipeline:`$out` stage.
183
+
182
184
The ``pipeline`` cannot directly access the input document
183
185
fields. Instead, first define the variables for the input
184
186
document fields, and then reference the variables in the stages
@@ -224,6 +226,30 @@ Views and Collation
224
226
225
227
.. include:: /includes/extracts/views-collation-agg.rst
226
228
229
+ Restrictions
230
+ ~~~~~~~~~~~~~
231
+
232
+ - .. versionchanged:: 4.2
233
+
234
+ You cannot include the :pipeline:`$out` stage in the
235
+ :pipeline:`$lookup` stage. That is, when specifying a :ref:`pipeline
236
+ for the joined collection <lookup-syntax-let-pipeline>`,
237
+ you cannot include the :pipeline:`$out` stage in the ``pipeline``
238
+ field.
239
+
240
+ .. code-block:: javascript
241
+ :emphasize-lines: 6
242
+
243
+ {
244
+ $lookup:
245
+ {
246
+ from: <collection to join>,
247
+ let: { <var_1>: <expression>, …, <var_n>: <expression> },
248
+ pipeline: [ <pipeline to execute on the joined collection> ], // Cannot include $out
249
+ as: <output array field>
250
+ }
251
+ }
252
+
227
253
Examples
228
254
--------
229
255
Original file line number Diff line number Diff line change @@ -311,8 +311,15 @@ The :pipeline:`$out` stage is not allowed as part of a :doc:`view
311
311
definition </core/views>`. If the view definition includes nested
312
312
pipeline (e.g. the view definition includes :pipeline:`$lookup` or
313
313
:pipeline:`$facet` stage), this :pipeline:`$out` stage restriction
314
- applies to the nested pipelines as well.
314
+ applies to the nested pipelines as well. [#lookup]_
315
315
316
+ .. [#lookup]
317
+
318
+ Starting in 4.2, you cannot include the :pipeline:`$out` stage in
319
+ the :pipeline:`$lookup` stage's :ref:`nested pipeline
320
+ <lookup-syntax-let-pipeline>`, regardless of whether the
321
+ :pipeline:`$lookup` is part of a view definition.
322
+
316
323
``linearizable`` Read Concern
317
324
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318
325
Original file line number Diff line number Diff line change @@ -253,6 +253,10 @@ Aggregation
253
253
<collMod>` with a new pipeline that does not contain the
254
254
:pipeline:`$out` stage.
255
255
256
+ - The :pipeline:`$lookup` stage cannot include the :pipeline:`$out`
257
+ stage in its nested :ref:`pipeline field for the joined collection
258
+ <lookup-syntax-let-pipeline>`.
259
+
256
260
- The :pipeline:`$out` stage cannot be used in conjunction with read
257
261
concern :readconcern:`"linearizable"`.
258
262
You can’t perform that action at this time.
0 commit comments