DATAMONGO-1550 - Add $replaceRoot aggregation stage.

We now support the $replaceRoot stage in aggregation pipelines. $replaceRoot can reference either a field, an aggregation expression or it can be used to compose a replacement document.

newAggregation(
	replaceRoot().withDocument()
		.andValue("value").as("field")
		.and(MULTIPLY.of(field("total"), field("discounted")))
);

newAggregation(
	replaceRoot("item")));

Original Pull Request: #422
This commit is contained in:
Mark Paluch
2016-12-07 16:18:57 +01:00
committed by Christoph Strobl
parent 1dea009e32
commit ae4cfaa58c
6 changed files with 771 additions and 3 deletions

View File

@@ -1676,7 +1676,7 @@ At the time of this writing we provide support for the following Aggregation Ope
[cols="2*"]
|===
| Pipeline Aggregation Operators
| project, skip, limit, lookup, unwind, group, sort, geoNear
| count, geoNear, group, limit, lookup, match, project, replaceRoot, skip, sort, unwind
| Set Aggregation Operators
| setEquals, setIntersection, setUnion, setDifference, setIsSubset, anyElementTrue, allElementsTrue