Class SetOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.SetOperation
- All Implemented Interfaces:
AggregationOperation, FieldsExposingAggregationOperation, FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
Adds new fields to documents.
$set outputs documents that contain all existing fields from the input
documents and newly added fields.
SetOperation.set("totalHomework").toValue("A+").and().set("totalQuiz").toValue("B-")
- Since:
- 3.0
- Author:
- Christoph Strobl
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation -
Constructor Summary
ConstructorsConstructorDescriptionSetOperation(Object field, @Nullable Object value) Create new instance ofSetOperation -
Method Summary
Modifier and TypeMethodDescriptionand()Concatenate additional fields to set.static SetOperation.FieldAppenderbuilder()Define theSetOperationviaSetOperation.FieldAppender.Returns the fields exposed by theAggregationOperation.Return the MongoDB operator that is used for thisAggregationOperation.protected StringAppend the value for a specific field to the operation.Concatenate another field to set.toDocument(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
-
SetOperation
Create new instance ofSetOperation- Parameters:
field- must not be null.value- can be null.
-
-
Method Details
-
builder
Define theSetOperationviaSetOperation.FieldAppender.- Returns:
- new instance of
SetOperation.FieldAppender.
-
set
Concatenate another field to set.- Parameters:
field- must not be null.- Returns:
- new instance of
SetOperation.FieldAppender.ValueAppender.
-
set
Append the value for a specific field to the operation.- Parameters:
field- the target field to set.value- the value to assign.- Returns:
- new instance of
SetOperation.
-
and
Concatenate additional fields to set.- Returns:
- new instance of
SetOperation.FieldAppender.
-
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.
-