Skip to content
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

Simplify AggregationExpression usage in Aggregation.project [DATAMONGO-2311] #3169

Open
spring-projects-issues opened this issue Jun 27, 2019 · 2 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 27, 2019

Christoph Strobl opened DATAMONGO-2311 and commented

Currently one has to call project().and(ctx -> ....)

by adding the following this could be reduced to project(ctx -> ...)

public ProjectionOperationBuilder and(AggregationExpression expression) {
	return new ProjectionOperationBuilder(expression, this, null);
}

Referenced from: pull request #769

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 2, 2019

Mark Paluch commented

We should make sure that method called on the actual ProjectionOperation consider the entire projection:

assertThat(project(ctx -> new Document("foo", 1)).andExclude("bar", "foo")
      .toDocument(Aggregation.DEFAULT_CONTEXT))
            .isEqualTo(new Document("$project", new Document("foo", 0).append("bar", 0))); 

Right now, the first document is exposed as _id field

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 2, 2019

Christoph Strobl commented

currently a Projection needs to expose a field which must not be the case if it's a document that can be dynamically created.
The solution in the PR needs to hold a projection instance in order to be chain able

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

Successfully merging a pull request may close this issue.

None yet
2 participants