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 |
|---|---|
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, waittoPipelineStagespublic 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_COLLECTIONpublic OutOperation replaceDocuments()
OutOperation.OutOperation.OutMode.REPLACEpublic OutOperation insertDocuments()
OutOperation.OutOperation.OutMode.INSERTpublic org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperationtoDocument in interface AggregationOperationcontext - the AggregationOperationContext to operate within. Must not be null.Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.