Class MergeOperation.MergeOperationBuilder
java.lang.Object
org.springframework.data.mongodb.core.aggregation.MergeOperation.MergeOperationBuilder
- Enclosing class:
MergeOperation
Builder API to construct a
MergeOperation.- Since:
- 2.3
- Author:
- Christoph Strobl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Expose the variables defined byVariableOperators.Letto theupdate aggregation.Set the identifier that determines if a results document matches an already existing document in the output collection.inDatabase(String database) Optionally define a target database if different from the current one.Define the target to store results in.intoCollection(String collection) Required output collection name to store results to.let(VariableOperators.Let let) Expose the variables defined byVariableOperators.Letto theupdate aggregation.Appends a single field or multiple fields that act as a unique identifier for a document.Define the target to store results in.whenDocumentsDontMatch(MergeOperation.WhenDocumentsDontMatch whenNotMatched) The action to take place when documents do not already exist in the target collection.whenDocumentsMatch(MergeOperation.WhenDocumentsMatch whenMatched) The action to take place when documents already exist in the target collection.whenDocumentsMatchApply(Aggregation aggregation) Theactionto take place when documents already exist in the target collection.whenMatched(MergeOperation.WhenDocumentsMatch whenMatched) The action to take place when documents already exist in the target collection.whenNotMatched(MergeOperation.WhenDocumentsDontMatch whenNotMatched) The action to take place when documents do not already exist in the target collection.
-
Constructor Details
-
MergeOperationBuilder
public MergeOperationBuilder()
-
-
Method Details
-
intoCollection
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder intoCollection(String collection) Required output collection name to store results to.- Parameters:
collection- must not be null nor empty.- Returns:
- this.
-
inDatabase
Optionally define a target database if different from the current one.- Parameters:
database- must not be null.- Returns:
- this.
-
into
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder into(MergeOperation.MergeOperationTarget into) Define the target to store results in.- Parameters:
into- must not be null.- Returns:
- this.
-
target
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder target(MergeOperation.MergeOperationTarget target) Define the target to store results in.- Parameters:
target- must not be null.- Returns:
- this.
-
on
Appends a single field or multiple fields that act as a unique identifier for a document. The identifier determines if a results document matches an already existing document in the output collection.
The aggregation results documents must contain the field(s) specified viaon, unless it's the_idfield.- Parameters:
fields- must not be null.- Returns:
- this.
-
id
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder id(MergeOperation.UniqueMergeId id) Set the identifier that determines if a results document matches an already existing document in the output collection.- Parameters:
id- must not be null.- Returns:
- this.
-
let
Expose the variables defined byVariableOperators.Letto theupdate aggregation.- Parameters:
let- the variable expressions- Returns:
- this.
-
exposeVariablesOf
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder exposeVariablesOf(VariableOperators.Let let) Expose the variables defined byVariableOperators.Letto theupdate aggregation.- Parameters:
let- the variable expressions- Returns:
- this.
-
whenMatched
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder whenMatched(MergeOperation.WhenDocumentsMatch whenMatched) The action to take place when documents already exist in the target collection.- Parameters:
whenMatched- must not be null.- Returns:
- this.
-
whenDocumentsMatch
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder whenDocumentsMatch(MergeOperation.WhenDocumentsMatch whenMatched) The action to take place when documents already exist in the target collection.- Parameters:
whenMatched- must not be null.- Returns:
- this.
-
whenDocumentsMatchApply
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder whenDocumentsMatchApply(Aggregation aggregation) Theactionto take place when documents already exist in the target collection.- Parameters:
aggregation- must not be null.- Returns:
- this.
-
whenNotMatched
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder whenNotMatched(MergeOperation.WhenDocumentsDontMatch whenNotMatched) The action to take place when documents do not already exist in the target collection.- Parameters:
whenNotMatched- must not be null.- Returns:
- this.
-
whenDocumentsDontMatch
@Contract("_ -> this") public MergeOperation.MergeOperationBuilder whenDocumentsDontMatch(MergeOperation.WhenDocumentsDontMatch whenNotMatched) The action to take place when documents do not already exist in the target collection.- Parameters:
whenNotMatched- must not be null.- Returns:
- this.
-
build
- Returns:
- new instance of
MergeOperation.
-