public class SetOperation extends Object
$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-")
| Modifier and Type | Class and Description |
|---|---|
static class |
SetOperation.FieldAppender |
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation| Constructor and Description |
|---|
SetOperation(Object field,
Object value)
Create new instance of
SetOperation |
| Modifier and Type | Method and Description |
|---|---|
SetOperation.FieldAppender |
and()
Concatenate additional fields to set.
|
static SetOperation.FieldAppender |
builder()
Define the
SetOperation via SetOperation.FieldAppender. |
ExposedFields |
getFields()
Returns the fields exposed by the
AggregationOperation. |
String |
getOperator()
Return the MongoDB operator that is used for this
AggregationOperation. |
protected Map<Object,Object> |
getValueMap() |
protected String |
mongoOperator() |
SetOperation |
set(Object field,
Object value)
Append the value for a specific field to the operation.
|
static SetOperation.FieldAppender.ValueAppender |
set(String field)
Concatenate another field to set.
|
org.bson.Document |
toDocument(AggregationOperationContext context)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinheritsFieldstoPipelineStagespublic SetOperation(Object field, @Nullable Object value)
SetOperationfield - must not be null.value - can be null.public static SetOperation.FieldAppender builder()
SetOperation via SetOperation.FieldAppender.SetOperation.FieldAppender.public static SetOperation.FieldAppender.ValueAppender set(String field)
field - must not be null.SetOperation.FieldAppender.ValueAppender.public SetOperation set(Object field, Object value)
field - the target field to set.value - the value to assign.SetOperation.public SetOperation.FieldAppender and()
SetOperation.FieldAppender.protected String mongoOperator()
public org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperationtoDocument in interface AggregationOperationcontext - the AggregationOperationContext to operate within. Must not be null.public String getOperator()
AggregationOperationAggregationOperation. Aggregation operations should
implement this method to avoid document rendering.getOperator in interface AggregationOperationAggregationOperation.public ExposedFields getFields()
FieldsExposingAggregationOperationAggregationOperation.getFields in interface FieldsExposingAggregationOperationCopyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.