public class ProjectionOperation extends Object implements FieldsExposingAggregationOperation
$project-operation.
Projection of field to be used in an Aggregation. A projection is similar to a Field
inclusion/exclusion but more powerful. It can generate new fields, change values of given field etc.
We recommend to use the static factory method Aggregation.project(Fields) instead of creating instances of
this class directly.
| Modifier and Type | Class and Description |
|---|---|
static class |
ProjectionOperation.ArrayProjectionOperationBuilder
Builder for
array projections. |
static class |
ProjectionOperation.ExpressionProjectionOperationBuilder
An
ProjectionOperation.ProjectionOperationBuilder that is used for SpEL expression based projections. |
static class |
ProjectionOperation.ProjectionOperationBuilder
Builder for
ProjectionOperations on a field. |
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation| Constructor and Description |
|---|
ProjectionOperation()
Creates a new empty
ProjectionOperation. |
ProjectionOperation(Class<?> type)
Creates a new
ProjectionOperation including all top level fields of the given type. |
ProjectionOperation(Fields fields)
Creates a new
ProjectionOperation including the given Fields. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittoPipelineStagespublic ProjectionOperation()
ProjectionOperation.public ProjectionOperation(Fields fields)
ProjectionOperation including the given Fields.fields - must not be null.public ProjectionOperation(Class<?> type)
ProjectionOperation including all top level fields of the given type.type - must not be null.public ProjectionOperation.ProjectionOperationBuilder and(String name)
ProjectionOperation.ProjectionOperationBuilder to define a projection for the field with the given name.name - must not be null or empty.public ProjectionOperation.ExpressionProjectionOperationBuilder andExpression(String expression, Object... params)
public ProjectionOperation.ProjectionOperationBuilder and(AggregationExpression expression)
public ProjectionOperation andExclude(String... fieldNames)
fieldNames - must not be null.public ProjectionOperation andInclude(String... fieldNames)
fieldNames - must not be null.public ProjectionOperation andInclude(Fields fields)
fields - must not be null.public ProjectionOperation asArray(String name)
ProjectionOperation as an array with given name. andArrayOf(Object...).name - the target property name.ProjectionOperation.public ProjectionOperation.ArrayProjectionOperationBuilder andArrayOf(Object... values)
field references, expression, plain values)
as an array. ProjectionOperation.ArrayProjectionOperationBuilder.as(String).values - must not be null.ProjectionOperation.ArrayProjectionOperationBuilder.IllegalArgumentException - if the required argument it null.public ExposedFields getFields()
FieldsExposingAggregationOperationAggregationOperation.getFields in interface FieldsExposingAggregationOperationpublic boolean inheritsFields()
inheritsFields in interface FieldsExposingAggregationOperationpublic org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperationtoDocument in interface AggregationOperationcontext - the AggregationOperationContext to operate within. Must not be null.public String getOperator()
AggregationOperationAggregationOperation. Aggregation operations should
implement this method to avoid document rendering.getOperator in interface AggregationOperationAggregationOperation.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.