Skip to content

DATAMONGO-1538 - Add support for $let to $project aggregation. #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

christophstrobl
Copy link
Member

We now support $let in aggregation $project stage.

newAggregation(Sales.class,
	project()
		.and(let(ADD.of(field("price"), field("tax"))).as("total")
			.andExpression(
				ConditionalOperator.newBuilder().when(field("applyDiscount")).then(0.9D).otherwise(1.0D))
			.as("discounted")
			.in(MULTIPLY.of(field("total"), field("discounted"))))
		.as("finalTotal"));

@christophstrobl christophstrobl force-pushed the issue/DATAMONGO-1538 branch 2 times, most recently from 8d4fa59 to d31b224 Compare December 6, 2016 05:12
We now support $let in aggregation $project stage.

ExpressionVariable total = newExpressionVariable("total").forExpression(ADD.of(field("price"), field("tax")));
ExpressionVariable discounted = newExpressionVariable("discounted").forExpression(Cond.when("applyDiscount").then(0.9D).otherwise(1.0D));

newAggregation(Sales.class,
	project()
		.and(define(total, discounted)
			.andApply(MULTIPLY.of(field("total"), field("discounted"))))
		.as("finalTotal"));
@mp911de mp911de force-pushed the issue/DATAMONGO-1538 branch from d31b224 to b6ee363 Compare December 6, 2016 14:27
Use InheritingExposedFieldsAggregationOperationContext instead of anonymous context class for condition operation. Drop aggregation input collections before tests. Minor reformatting.
@mp911de mp911de force-pushed the issue/DATAMONGO-1538 branch from b6ee363 to f0a7bf4 Compare December 7, 2016 08:15
mp911de pushed a commit that referenced this pull request Dec 7, 2016
We now support $let in aggregation $project stage.

ExpressionVariable total = newExpressionVariable("total").forExpression(ADD.of(field("price"), field("tax")));
ExpressionVariable discounted = newExpressionVariable("discounted").forExpression(Cond.when("applyDiscount").then(0.9D).otherwise(1.0D));

newAggregation(Sales.class,
	project()
		.and(define(total, discounted)
			.andApply(MULTIPLY.of(field("total"), field("discounted"))))
		.as("finalTotal"));

Original pull request: #417.
mp911de added a commit that referenced this pull request Dec 7, 2016
Use InheritingExposedFieldsAggregationOperationContext instead of anonymous context class for condition mapping. Drop aggregation input collections before tests. Minor reformatting.

Original pull request: #417.
mp911de pushed a commit that referenced this pull request Dec 7, 2016
We now support $let in aggregation $project stage.

ExpressionVariable total = newExpressionVariable("total").forExpression(ADD.of(field("price"), field("tax")));
ExpressionVariable discounted = newExpressionVariable("discounted").forExpression(Cond.when("applyDiscount").then(0.9D).otherwise(1.0D));

newAggregation(Sales.class,
	project()
		.and(define(total, discounted)
			.andApply(MULTIPLY.of(field("total"), field("discounted"))))
		.as("finalTotal"));

Original pull request: #417.
mp911de added a commit that referenced this pull request Dec 7, 2016
Use InheritingExposedFieldsAggregationOperationContext instead of anonymous context class for condition mapping. Drop aggregation input collections before tests. Minor reformatting.

Original pull request: #417.
@mp911de
Copy link
Member

mp911de commented Dec 7, 2016

That's merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants