Class OutOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.OutOperation
- All Implemented Interfaces:
AggregationOperation
Encapsulates the
$out
-operation.
We recommend to use the static factory method Aggregation.out(String)
instead of creating instances of this
class directly.
- Author:
- Nikolay Bogdanov, Christoph Strobl
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The mode for merging the aggregation pipeline output. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn the MongoDB operator that is used for thisAggregationOperation
.Optionally specify the database of the target collection.Insert documents to the target collection.mode
(OutOperation.OutMode mode) Specify how to merge the aggregation output with the target collection.Replace the target collection.Replace/Upsert documents in the target collection.org.bson.Document
toDocument
(AggregationOperationContext context) Optionally specify the field that uniquely identifies a document in the target collection.uniqueKeyOf
(Iterable<String> fields) Optionally specify the fields that uniquely identifies a document in the target collection.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
-
Constructor Details
-
OutOperation
- Parameters:
outCollectionName
- Collection name to export the results. Must not be null.
-
-
Method Details
-
in
Optionally specify the database of the target collection.
NOTE: Requires MongoDB 4.2 or later.- Parameters:
database
- can be null. Defaulted to aggregation target database.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
-
uniqueKey
Optionally specify the field that uniquely identifies a document in the target collection.
For convenience the given key can either be a single field name or the Json representation of a keyDocument
.// { // "field-1" : 1 // } .uniqueKey("field-1") // { // "field-1" : 1, // "field-2" : 1 // } .uniqueKey("{ 'field-1' : 1, 'field-2' : 1}")
NOTE: Requires MongoDB 4.2 or later.- Parameters:
key
- can be null. Server uses _id when null.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
-
uniqueKeyOf
Optionally specify the fields that uniquely identifies a document in the target collection.
// { // "field-1" : 1 // "field-2" : 1 // } .uniqueKeyOf(Arrays.asList("field-1", "field-2"))
NOTE: Requires MongoDB 4.2 or later.- Parameters:
fields
- must not be null.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
-
mode
Specify how to merge the aggregation output with the target collection.
NOTE: Requires MongoDB 4.2 or later.- Parameters:
mode
- must not be null.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
-
replaceCollection
Replace the target collection.
NOTE: Requires MongoDB 4.2 or later.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
- See Also:
-
replaceDocuments
Replace/Upsert documents in the target collection.
NOTE: Requires MongoDB 4.2 or later.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
- See Also:
-
insertDocuments
Insert documents to the target collection.
NOTE: Requires MongoDB 4.2 or later.- Returns:
- new instance of
OutOperation
. - Since:
- 2.2
- See Also:
-
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
.
-