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, Kim Sumin
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation -
Constructor Summary
ConstructorsConstructorDescriptionAddFieldsOperation(Object field, @Nullable 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 theAddFieldsOperationviaAddFieldsOperation.AddFieldsOperationBuilder.Returns the fields exposed by theAggregationOperation.Return the MongoDB operator that is used for thisAggregationOperation.protected StringtoDocument(AggregationOperationContext context) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AggregationOperation
toPipelineStagesMethods inherited from interface FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
inheritsFields
-
Constructor Details
-
AddFieldsOperation
Create new instance ofAddFieldsOperation- Parameters:
field- must not be null.value- can be null.
-
-
Method Details
-
builder
Define theAddFieldsOperationviaAddFieldsOperation.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:
toDocumentin interfaceAggregationOperation- Parameters:
context- theAggregationOperationContextto operate within. Must not be null.- Returns:
- the Document
-
getOperator
Description copied from interface:AggregationOperationReturn the MongoDB operator that is used for thisAggregationOperation. Aggregation operations should implement this method to avoid document rendering.- Specified by:
getOperatorin interfaceAggregationOperation- Returns:
- the operator used for this
AggregationOperation.
-
getValueMap
-
getFields
Description copied from interface:FieldsExposingAggregationOperationReturns the fields exposed by theAggregationOperation.- Specified by:
getFieldsin interfaceFieldsExposingAggregationOperation- Returns:
- will never be null.
-