public class Aggregation extends Object
Aggregation
is a representation of a list of aggregation steps to be performed by the MongoDB Aggregation
Framework.Modifier and Type | Field and Description |
---|---|
static AggregationOperationContext |
DEFAULT_CONTEXT |
Modifier | Constructor and Description |
---|---|
protected |
Aggregation(AggregationOperation... aggregationOperations)
Creates a new
Aggregation from the given AggregationOperation s. |
Modifier and Type | Method and Description |
---|---|
static Fields |
bind(String name,
String target)
Creates a new
Fields instance from the given field name and target reference. |
static Fields |
fields(String... fields)
Creates a new
Fields instance for the given field names. |
static GroupOperation |
group(Fields fields)
Creates a new
GroupOperation for the given Fields . |
static GroupOperation |
group(String... fields)
Creates a new
GroupOperation for the given fields. |
static org.springframework.data.mongodb.core.aggregation.LimitOperation |
limit(long maxElements)
Creates a new
LimitOperation limiting the result to the given number of elements. |
static MatchOperation |
match(Criteria criteria)
Creates a new
MatchOperation using the given Criteria . |
static Aggregation |
newAggregation(AggregationOperation... operations)
Creates a new
Aggregation from the given AggregationOperation s. |
static <T> TypedAggregation<T> |
newAggregation(Class<T> type,
AggregationOperation... operations)
Creates a new
TypedAggregation for the given type and AggregationOperation s. |
static <T> TypedAggregation<T> |
newAggregation(Class<T> type,
List<? extends AggregationOperation> operations)
Creates a new
TypedAggregation for the given type and AggregationOperation s. |
static Aggregation |
newAggregation(List<? extends AggregationOperation> operations)
Creates a new
Aggregation from the given AggregationOperation s. |
static String |
previousOperation()
A pointer to the previous
AggregationOperation . |
static ProjectionOperation |
project(Fields fields)
Creates a new
ProjectionOperation includeing the given Fields . |
static ProjectionOperation |
project(String... fields)
Creates a new
ProjectionOperation including the given fields. |
static SkipOperation |
skip(int elementsToSkip)
Creates a new
SkipOperation skipping the given number of elements. |
static SortOperation |
sort(Sort.Direction direction,
String... fields)
|
static SortOperation |
sort(Sort sort)
Factory method to create a new
SortOperation for the given Sort . |
com.mongodb.DBObject |
toDbObject(String inputCollectionName,
AggregationOperationContext rootContext)
Converts this
Aggregation specification to a DBObject . |
String |
toString() |
static UnwindOperation |
unwind(String field)
Factory method to create a new
UnwindOperation for the field with the given name. |
public static final AggregationOperationContext DEFAULT_CONTEXT
protected Aggregation(AggregationOperation... aggregationOperations)
Aggregation
from the given AggregationOperation
s.aggregationOperations
- must not be null or empty.public static Aggregation newAggregation(List<? extends AggregationOperation> operations)
Aggregation
from the given AggregationOperation
s.operations
- must not be null or empty.public static Aggregation newAggregation(AggregationOperation... operations)
Aggregation
from the given AggregationOperation
s.operations
- must not be null or empty.public static <T> TypedAggregation<T> newAggregation(Class<T> type, List<? extends AggregationOperation> operations)
TypedAggregation
for the given type and AggregationOperation
s.type
- must not be null.operations
- must not be null or empty.public static <T> TypedAggregation<T> newAggregation(Class<T> type, AggregationOperation... operations)
TypedAggregation
for the given type and AggregationOperation
s.type
- must not be null.operations
- must not be null or empty.public static String previousOperation()
AggregationOperation
.public static ProjectionOperation project(String... fields)
ProjectionOperation
including the given fields.fields
- must not be null.public static ProjectionOperation project(Fields fields)
ProjectionOperation
includeing the given Fields
.fields
- must not be null.public static UnwindOperation unwind(String field)
UnwindOperation
for the field with the given name.fieldName
- must not be null or empty.public static GroupOperation group(String... fields)
GroupOperation
for the given fields.fields
- must not be null.public static GroupOperation group(Fields fields)
GroupOperation
for the given Fields
.fields
- must not be null.public static SortOperation sort(Sort sort)
SortOperation
for the given Sort
.sort
- must not be null.public static SortOperation sort(Sort.Direction direction, String... fields)
direction
- must not be null.fields
- must not be null.public static SkipOperation skip(int elementsToSkip)
SkipOperation
skipping the given number of elements.elementsToSkip
- must not be less than zero.public static org.springframework.data.mongodb.core.aggregation.LimitOperation limit(long maxElements)
LimitOperation
limiting the result to the given number of elements.maxElements
- must not be less than zero.public static MatchOperation match(Criteria criteria)
MatchOperation
using the given Criteria
.criteria
- must not be null.public static Fields fields(String... fields)
Fields
instance for the given field names.fields
- must not be null.Fields.fields(String...)
public static Fields bind(String name, String target)
Fields
instance from the given field name and target reference.name
- must not be null or empty.target
- must not be null or empty.public com.mongodb.DBObject toDbObject(String inputCollectionName, AggregationOperationContext rootContext)
Aggregation
specification to a DBObject
.inputCollectionName
- the name of the input collectionDBObject
representing this aggregationCopyright © 2011-2013-2013 Pivotal. All Rights Reserved.