Skip to content

Commit 82ee1d4

Browse files
author
Kay Kim
committed
DOCS-12330: $out and $limit restrictions
1 parent 68b2f09 commit 82ee1d4

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

source/reference/operator/aggregation/lookup.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ The :pipeline:`$lookup` takes a document with the following fields:
179179
collection. To return all documents, specify an empty pipeline
180180
``[]``.
181181

182+
The ``pipeline`` cannot include the :pipeline:`$out` stage.
183+
182184
The ``pipeline`` cannot directly access the input document
183185
fields. Instead, first define the variables for the input
184186
document fields, and then reference the variables in the stages
@@ -224,6 +226,30 @@ Views and Collation
224226

225227
.. include:: /includes/extracts/views-collation-agg.rst
226228

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+
227253
Examples
228254
--------
229255

source/reference/operator/aggregation/out.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,15 @@ The :pipeline:`$out` stage is not allowed as part of a :doc:`view
311311
definition </core/views>`. If the view definition includes nested
312312
pipeline (e.g. the view definition includes :pipeline:`$lookup` or
313313
: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]_
315315

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+
316323
``linearizable`` Read Concern
317324
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318325

source/release-notes/4.2-compatibility.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ Aggregation
253253
<collMod>` with a new pipeline that does not contain the
254254
:pipeline:`$out` stage.
255255

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+
256260
- The :pipeline:`$out` stage cannot be used in conjunction with read
257261
concern :readconcern:`"linearizable"`.
258262

0 commit comments

Comments
 (0)