public class MergeOperation extends Object implements FieldsExposingAggregationOperation, FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
$merge
-operation.
We recommend to use the builder
via builder()
instead of
creating instances of this class directly.
Modifier and Type | Class and Description |
---|---|
static class |
MergeOperation.MergeOperationBuilder
Builder API to construct a
MergeOperation . |
static class |
MergeOperation.MergeOperationTarget
Value Object representing the
into field of a $merge aggregation stage. |
static class |
MergeOperation.UniqueMergeId
Value object representing the unique id used during the merge operation to identify duplicates in the target
collection.
|
static class |
MergeOperation.WhenDocumentsDontMatch
Value Object specifying how to deal with a result document that do not match an existing document in the collection
based on the fields of the
on property describing the unique identifier. |
static class |
MergeOperation.WhenDocumentsMatch
Value Object specifying how to deal with a result document that matches an existing document in the collection
based on the fields of the
on property describing the unique identifier. |
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
Constructor and Description |
---|
MergeOperation(MergeOperation.MergeOperationTarget into,
MergeOperation.UniqueMergeId on,
VariableOperators.Let let,
MergeOperation.WhenDocumentsMatch whenMatched,
MergeOperation.WhenDocumentsDontMatch whenNotMatched)
Create new instance of
MergeOperation . |
Modifier and Type | Method and Description |
---|---|
static MergeOperation.MergeOperationBuilder |
builder()
Access the
builder API to create a new instance of MergeOperation . |
ExposedFields |
getFields()
Returns the fields exposed by the
AggregationOperation . |
boolean |
inheritsFields() |
static MergeOperation |
mergeInto(String collection)
Simplified form to apply all default options for
$merge (including writing to a collection in the same
database). |
org.bson.Document |
toDocument(AggregationOperationContext context)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toPipelineStages
public MergeOperation(MergeOperation.MergeOperationTarget into, MergeOperation.UniqueMergeId on, @Nullable VariableOperators.Let let, @Nullable MergeOperation.WhenDocumentsMatch whenMatched, @Nullable MergeOperation.WhenDocumentsDontMatch whenNotMatched)
MergeOperation
.into
- the target (collection and database)on
- the unique identifier. Can be null.let
- exposed variables for MergeOperation.WhenDocumentsMatch.updateWith(Aggregation)
. Can be null.whenMatched
- behavior if a result document matches an existing one in the target collection. Can be
null.whenNotMatched
- behavior if a result document does not match an existing one in the target collection. Can be
null.public static MergeOperation mergeInto(String collection)
$merge
(including writing to a collection in the same
database).collection
- the output collection within the same database.MergeOperation
.public static MergeOperation.MergeOperationBuilder builder()
builder API
to create a new instance of MergeOperation
.MergeOperation.MergeOperationBuilder
.public org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperation
toDocument
in interface AggregationOperation
context
- the AggregationOperationContext
to operate within. Must not be null.public ExposedFields getFields()
FieldsExposingAggregationOperation
AggregationOperation
.getFields
in interface FieldsExposingAggregationOperation
public boolean inheritsFields()
inheritsFields
in interface FieldsExposingAggregationOperation
inheritsFields
in interface FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.