From 6e5f3661a810ac5c90bb55db67203b959bde96b3 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 17 Oct 2013 13:27:01 +0200 Subject: [PATCH] DATAMONGO-774 - Some polishing in the reference documentation. --- src/docbkx/reference/mongodb.xml | 56 ++++++++++++-------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/src/docbkx/reference/mongodb.xml b/src/docbkx/reference/mongodb.xml index abe5acdbb..7106f4e7e 100644 --- a/src/docbkx/reference/mongodb.xml +++ b/src/docbkx/reference/mongodb.xml @@ -1550,8 +1550,9 @@ List<Person> result = mongoTemplate.find(query(where("age").lt(50) and Query.query to make the query more readable. - This query should return a list of Person objects that meet the - specified criteria. The Criteria class has the following methods that + This query should return a list of Person + objects that meet the specified criteria. The + Criteria class has the following methods that correspond to the operators provided in MongoDB. As you can see most methods return the @@ -2414,23 +2415,17 @@ project("a","b").and("foo").as("bar") // will generate {$project: {a: 1, b: 1, b be found in the corresponding section of the MongoDB Aggregation Framework reference - documentation. + documentation.
Spring Expresison Support in Projection Expressions - Since Version 1.4.0 we support the use of SpEL expression in - Projection expressions via the andExpression + As of Version 1.4.0 we support the use of SpEL expression in + projection expressions via the andExpression method of the ProjectionOperation class. This - allows a developer to define the desired expression as a SpEL - expression string which is then translated to a corresponding MongoDB - projection expression part on query execution. - - Note that one can find more usage examples for supported SpEL - expression constructs in - SpelExpressionToMongoExpressionTransformerUnitTests. - - This makes it much easier to express complex + allows you to define the desired expression as a SpEL expression which + is translated into a corresponding MongoDB projection expression part + on query execution. This makes it much easier to express complex calculations. @@ -2443,28 +2438,19 @@ project("a","b").and("foo").as("bar") // will generate {$project: {a: 1, b: 1, b will be translated into the following projection expression part: - { - "$add":[ - 1, - { - "$divide":[ - { - "$add":[ - "$q", - 1 - ] - }, - { - "$subtract":[ - "$q", - 1 - ] - } - ] - } - ] -} + { "$add" : [ 1, { + "$divide" : [ { + "$add":["$q", 1]}, { + "$subtract":[ "$q", 1]} + ] +}]} + + Have a look at an example in more context in and . You can find more + usage examples for supported SpEL expression constructs in + SpelExpressionTransformerUnitTests.