Class AddFieldsOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.AddFieldsOperation
- All Implemented Interfaces:
AggregationOperation
,FieldsExposingAggregationOperation
,FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
Adds new fields to documents.
$addFields
outputs documents that contain all existing fields from the input
documents and newly added fields.
AddFieldsOperation.addField("totalHomework").withValue("A+").and().addField("totalQuiz").withValue("B-")
- Since:
- 3.0
- Author:
- Christoph Strobl
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
-
Constructor Summary
ConstructorDescriptionAddFieldsOperation
(Object field, Object value) Create new instance ofAddFieldsOperation
-
Method Summary
Modifier and TypeMethodDescriptionAppend the value for a specific field to the operation.Concatenate another field to add.and()
Concatenate additional fields to add.builder()
Define theAddFieldsOperation
viaAddFieldsOperation.AddFieldsOperationBuilder
.Returns the fields exposed by theAggregationOperation
.Return the MongoDB operator that is used for thisAggregationOperation
.protected String
org.bson.Document
toDocument
(AggregationOperationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.AggregationOperation
toPipelineStages
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
inheritsFields
-
Constructor Details
-
AddFieldsOperation
Create new instance ofAddFieldsOperation
- Parameters:
field
- must not be null.value
- can be null.
-
-
Method Details
-
builder
Define theAddFieldsOperation
viaAddFieldsOperation.AddFieldsOperationBuilder
.- Returns:
- new instance of
AddFieldsOperation.AddFieldsOperationBuilder
.
-
addField
Concatenate another field to add.- Parameters:
field
- must not be null.- Returns:
- new instance of
AddFieldsOperation.AddFieldsOperationBuilder
.
-
addField
Append the value for a specific field to the operation.- Parameters:
field
- the target field to add.value
- the value to assign.- Returns:
- new instance of
AddFieldsOperation
.
-
and
Concatenate additional fields to add.- Returns:
- new instance of
AddFieldsOperation.AddFieldsOperationBuilder
.
-
mongoOperator
- Returns:
- the String representation of the native MongoDB operator.
-
toDocument
Description copied from interface:AggregationOperation
- Specified by:
toDocument
in interfaceAggregationOperation
- Parameters:
context
- theAggregationOperationContext
to operate within. Must not be null.- Returns:
- the Document
-
getOperator
Description copied from interface:AggregationOperation
Return the MongoDB operator that is used for thisAggregationOperation
. Aggregation operations should implement this method to avoid document rendering.- Specified by:
getOperator
in interfaceAggregationOperation
- Returns:
- the operator used for this
AggregationOperation
.
-
getValueMap
- Returns:
- the raw value map
-
getFields
Description copied from interface:FieldsExposingAggregationOperation
Returns the fields exposed by theAggregationOperation
.- Specified by:
getFields
in interfaceFieldsExposingAggregationOperation
- Returns:
- will never be null.
-