Skip to content

Commit 54c3c9e

Browse files
author
Sam Kleinman
committed
edits to aggregation $out behavior
1 parent 8487b29 commit 54c3c9e

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

source/release-notes/2.6.txt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,26 @@ Aggregation Pipeline Changes
8888
:pipeline:`$out`.
8989

9090
:pipeline:`$out` will create a new collection if one does not
91-
already exist in the current database. This collection will not be
92-
visible at that name until the aggregation completes. If the aggregation
93-
fails part-way through, no collection will be created.
94-
95-
If the output collection already exists, the behavior is the same
96-
as MapReduce's replace mode. To be specific if the aggregation completes
97-
successfully, the output collection will be atomically replaced by a newer
98-
version. Any indexes that existed at the start of the aggregation on the
99-
original output collection will also exist on the new collection.
100-
Importantly, this means that the pipeline will error out if the output
101-
documents would violate any unique indexes (including _id) that existed
102-
on the original output collection.
91+
already exist in the current database. This collection is not
92+
visible until the aggregation completes. If the aggregation
93+
fails, no collection MongoDB will not create any collection.
10394

95+
If the output collection already exists, when the aggregation
96+
completes *successfully*, the :pipeline:`$out` atomically replaces
97+
the output collection with the new results
98+
collection. :pipeline:`$out` does not change any indexes that
99+
existed on the previous collection.
100+
101+
.. important:: The pipeline will fail to complete if the documents
102+
produced by the pipeline would violate any unique indexes,
103+
including the index on the ``_id`` field, that existed on the
104+
original output collection.
104105

105106
You may *only* specify :pipeline:`$out` at the end of a pipeline.
106107

108+
With :pipeline:`$out`, the aggregation framework can return result
109+
sets of any size.
110+
107111
.. example::
108112

109113
The following operation will insert all documents in ``records``
@@ -116,8 +120,10 @@ Aggregation Pipeline Changes
116120
db.records.aggregate( { $project: { uid: 1, email: 1 } },
117121
{ $out: "users" } )
118122

119-
With :pipeline:`$out`, the aggregation framework can return result
120-
sets of any size.
123+
.. [#same-as-replace] When the :pipeline:`$out` operation specifies
124+
a collection that already exists in the current database,
125+
:pipeline:`$out` behaves like the replace mode of
126+
:dbcommand:`mapReduce`.
121127

122128
Aggregation Operation May Return a Cursor
123129
`````````````````````````````````````````

0 commit comments

Comments
 (0)