Comments (4)
Hey @vittoN :)
I am not sure if I have understood correctly your suggestion, can you give an example of how would you use that in a filter query?
from springfilter.
Let's assume i would extract all messages where recipient is the user logged in the system. So, using a custom JPA query i'll write:
@Query("select m from Message m where m.to.id = ?#{ principal?.id }")
Page<Message> findInbox(Pageable pageable);
I would like a way to limit searched results in the same way using spring-filter.
from springfilter.
I see what you mean, I think it will be quiet hard to support @Query
. What you can do is anding the user's filter with an another filter:
Specification<Message> incomingFilter = // user's filter
Specification<Message> loggedInUserFilter = new FilterSpecification<Message>(FilterBuilder.equal("principal.id", getLoggedInUserId()));
Specification<Message> finalFilter = FilterSpecification.merge(incomingFilter, loggedInUserFilter); // or Specification.where(loggedInUserFilter).and(incomingFilter);
Page<Message> messages = repository.findAll(finalFilter, pageable);
That way, no matter what the user's filter is, he will only and only be able to get/filter his own messages.
Hope it's clear.
from springfilter.
@vittoN I think that anding filters should have met your requirements, closing the issue for now.
from springfilter.
Related Issues (20)
- Conflicting ConversionService HOT 1
- Avoid duplicates HOT 5
- Escaping wildcard characters in "LIKE" queries HOT 2
- Add multiple joins in nested list HOT 1
- [MongoDB] $in with ObjectId HOT 2
- Global case insensitive search HOT 1
- Opportunity to use functions on the right side of the comparators HOT 1
- Discord Server HOT 2
- Unable to filter on List of Strings HOT 2
- Add new module for deserialization in the @Filter annotation HOT 4
- Implement `NotLike` value comparator. HOT 1
- Mongo filter collections HOT 3
- Showcase - how do you use Spring Filter? HOT 1
- Customizing the escape character for like operations (`~` and `~~`) HOT 3
- Filter by Map in Mongo HOT 1
- Mongo filtering nested fields not working in 3.x.x version HOT 2
- Case insensitive equals search
- Possible to filter without Spring boot controller? HOT 1
- MongoDB - query by DBRef HOT 2
- Make field not searchable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springfilter.