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

Add support for restricting results by document types in the @Query annotation [DATAMONGO-2151] #3020

Open
spring-projects-issues opened this issue Nov 29, 2018 · 0 comments
Assignees
Labels
in: core type: enhancement

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Nov 29, 2018

tinesoft opened DATAMONGO-2151 and commented

Since #53, it is now possible to  restrict results of a query to specific types, thanks to the new 'restrict ()' method on the Query object.

it would be nice if this feature could be made available on the @Query annotation as well.

This could be done, for example, via a restrict parameter that would accept a array of Class<?>, just like the restrict method on the Query class.

For example:

@Query(restrict={BaseDoc.class, SpecialDoc1.class, SpecialDoc2.class})
BaseDoc findBySomething();

 

Of course i could also use:

@Query(" '_class': {'$in': ['com.mydomain.BaseDoc', 'com.mydomain.SpecialDoc1', 'com.mydomain.SpecialDoc2']}")
BaseDoc findBySomething();

 
to do the job, but i'm looking for a more typesafe approach. Beside i would like to still be able to use the query method mechanism to generate the actual query.

 


Affects: 2.0.12 (Kay SR12)

@spring-projects-issues spring-projects-issues added type: enhancement in: core labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants