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 classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
-
Constructor Summary
ConstructorDescriptionSetOperation
(Object field, Object value) Create new instance ofSetOperation
-
Method Summary
Modifier and TypeMethodDescriptionand()
Concatenate additional fields to set.static SetOperation.FieldAppender
builder()
Define theSetOperation
viaSetOperation.FieldAppender
.Returns the fields exposed by theAggregationOperation
.Return the MongoDB operator that is used for thisAggregationOperation
.protected String
Append the value for a specific field to the operation.Concatenate another field to set.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
-
SetOperation
Create new instance ofSetOperation
- Parameters:
field
- must not be null.value
- can be null.
-
-
Method Details
-
builder
Define theSetOperation
viaSetOperation.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:
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.
-