13.07.2015 Views

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

please define productname in your docbook file!• Boolean Aggregation Operators• Comparison Aggregation Operators• Arithmetic Aggregation Operators• String Aggregation Operators• Date Aggregation Operators• Conditional Aggregation OperatorsAt the time of this writing we provide support for the following Aggregation Operations in <strong>Spring</strong> <strong>Data</strong><strong>MongoDB</strong>.Table 5.1. Aggregation Operations currently supported by <strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong>Pipeline Aggregation OperatorsGroup Aggregation OperatorsArithmetic Aggregation OperatorsComparison Aggregation Operatorsproject, skip, limit, unwind, group, sort, geoNearaddToSet, first, last, max, min, avg, push, sum,(*count)add (*via plus), subtract (*via minus), multiply,divide, modeq (*via: is), gt, gte, lt, lte, neNote that the aggregation operations not listed here are currently not supported by <strong>Spring</strong> <strong>Data</strong><strong>MongoDB</strong>. Comparison aggregation operators are expressed as Criteria expressions.*) The operation is mapped or added by <strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong>.Projection ExpressionsProjection expressions are used to define the fields that are the outcome of a particular aggregationstep. Projection expressions can be defined via the project method of the Aggregate class.project("name", "netPrice") // will generate {$project: {name: 1, netPrice: 1}}project().and("foo").as("bar") // will generate {$project: {bar: $foo}}project("a","b").and("foo").as("bar") // will generate {$project: {a: 1, b: 1, bar: $foo}}Note that more examples for project operations can be found in the AggregationTests class.Example 5.15 Projection expression examplesNote that further details regarding the projection expressions can be found in the corresponding sectionof the <strong>MongoDB</strong> Aggregation Framework reference documentation.<strong>Spring</strong> Expresison Support in Projection ExpressionsAs of Version 1.4.0 we support the use of SpEL expression in projection expressions via theandExpression method of the ProjectionOperation class. This allows you to define the desiredexpression as a SpEL expression which is translated into a corresponding <strong>MongoDB</strong> projectionexpression part on query execution. This makes it much easier to express complex calculations.1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!