Class MergeOperation.WhenDocumentsMatch
java.lang.Object
org.springframework.data.mongodb.core.aggregation.MergeOperation.WhenDocumentsMatch
- Enclosing class:
- MergeOperation
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.- Since:
- 2.3
- Author:
- Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptionStop and fail the aggregation operation.Keep the existing document in the output collection.Merge the matching documents.Replace the existing document in the output collection with the matching results document.updateWith
(List<AggregationOperation> aggregationPipeline) Use an aggregation pipeline to update the document in the collection.updateWith
(Aggregation aggregation) Use anAggregation
to update the document in the collection.whenMatchedOf
(String value)
-
Method Details
-
whenMatchedOf
-
replaceDocument
Replace the existing document in the output collection with the matching results document.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-
keepExistingDocument
Keep the existing document in the output collection.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-
mergeDocuments
Merge the matching documents. Please see the MongoDB reference documentation for details.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-
failOnMatch
Stop and fail the aggregation operation. Does not revert already performed changes on previous documents.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-
updateWith
Use anAggregation
to update the document in the collection. Please see the MongoDB reference documentation for details.- Parameters:
aggregation
- must not be null.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-
updateWith
public static MergeOperation.WhenDocumentsMatch updateWith(List<AggregationOperation> aggregationPipeline) Use an aggregation pipeline to update the document in the collection. Please see the MongoDB reference documentation for details.- Parameters:
aggregationPipeline
- must not be null.- Returns:
- new instance of
MergeOperation.WhenDocumentsMatch
.
-