public class OutOperation extends Object implements AggregationOperation
$out
-operation.
We recommend to use the static factory method Aggregation.out(String)
instead of creating instances of this
class directly.
Modifier and Type | Class and Description |
---|---|
static class |
OutOperation.OutMode
The mode for merging the aggregation pipeline output.
|
Constructor and Description |
---|
OutOperation(String outCollectionName) |
Modifier and Type | Method and Description |
---|---|
String |
getOperator()
Return the MongoDB operator that is used for this
AggregationOperation . |
OutOperation |
in(String database)
Optionally specify the database of the target collection.
|
OutOperation |
insertDocuments()
Insert documents to the target collection.
|
OutOperation |
mode(OutOperation.OutMode mode)
Specify how to merge the aggregation output with the target collection.
|
OutOperation |
replaceCollection()
Replace the target collection.
|
OutOperation |
replaceDocuments()
Replace/Upsert documents in the target collection.
|
org.bson.Document |
toDocument(AggregationOperationContext context)
|
OutOperation |
uniqueKey(String key)
Optionally specify the field that uniquely identifies a document in the target collection.
|
OutOperation |
uniqueKeyOf(Iterable<String> fields)
Optionally specify the fields that uniquely identifies a document in the target collection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toPipelineStages
public OutOperation(String outCollectionName)
outCollectionName
- Collection name to export the results. Must not be null.public OutOperation in(@Nullable String database)
database
- can be null. Defaulted to aggregation target database.OutOperation
.public OutOperation uniqueKey(@Nullable String key)
Document
.
// { // "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.
key
- can be null. Server uses _id when null.OutOperation
.public OutOperation uniqueKeyOf(Iterable<String> fields)
// { // "field-1" : 1 // "field-2" : 1 // } .uniqueKeyOf(Arrays.asList("field-1", "field-2"))NOTE: Requires MongoDB 4.2 or later.
fields
- must not be null.OutOperation
.public OutOperation mode(OutOperation.OutMode mode)
mode
- must not be null.OutOperation
.public OutOperation replaceCollection()
OutOperation
.OutOperation.OutMode.REPLACE_COLLECTION
public OutOperation replaceDocuments()
OutOperation
.OutOperation.OutMode.REPLACE
public OutOperation insertDocuments()
OutOperation
.OutOperation.OutMode.INSERT
public org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperation
toDocument
in interface AggregationOperation
context
- the AggregationOperationContext
to operate within. Must not be null.public String getOperator()
AggregationOperation
AggregationOperation
. Aggregation operations should
implement this method to avoid document rendering.getOperator
in interface AggregationOperation
AggregationOperation
.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.