Package dev.morphia.aggregation.stages
Class ReplaceRoot
java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.ReplaceRoot
Replaces the input document with the specified document. The operation replaces all existing fields in the input document, including
the _id field.
-
Method Summary
Modifier and TypeMethodDescriptionfield
(String name, Expression expression) Adds a new fieldstatic ReplaceRoot
Creates a new stagestatic ReplaceRoot
replaceRoot
(Object expression) Creates a new stage to replace the root with the given expression.
-
Method Details
-
replaceRoot
Creates a new stage- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $replaceRoot
- Since server release
- 3.4
-
replaceRoot
Creates a new stage to replace the root with the given expression. This expression must evaluate to a document. No further fields can be added to this stage.- Parameters:
expression
- the document expression- Returns:
- the new stage
- Since:
- 2.2
-
field
Adds a new field- Parameters:
name
- the field nameexpression
- the value expression- Returns:
- this
-