Reputation: 373
I've an API in springboot which gets the data from mongo DB. This API accepts 4 filters:
Now, the user can send any of the filters or all filters. Example, if he passes just name and role, I should filter the data by name and role ignoring date fields. If he sends all values, I should filter by all fields. If he sends just from date, I should filter by from date ignoring all fields.
Can someone help me with this plesae?
Thank you
Upvotes: 0
Views: 1093
Reputation: 461
Try Specifications
from Spring Data JPA.
Documentation link - https://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/
Upvotes: 1