- Notifications
You must be signed in to change notification settings - Fork19
Use the MongoDB query language to query your relational database, typically from frontend.
License
NotificationsYou must be signed in to change notification settings
mhewedy/spring-data-jpa-mongodb-expressions
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Customize JPA Repository base class:
@SpringBootApplication@EnableJpaRepositories(repositoryBaseClass =ExpressionsRepositoryImpl.class)publicclassApplication { … }
- Change your repository to extend
ExpressionsRepository:@RepositorypublicinterfaceEmployeeRepositoryextendsExpressionsRepository<Employee,Long> {}
- Build the controller/service:
@PostMapping("/search")publicResponseEntity<Page<EmployeeDto>>search(@RequestBodyExpressionsexpressions,Pageablepageable) {returnok().body(employeeRepository.findAll(expressions,pageable).map(employeeMapper::toDto) );}
- SendMongodb query in JSON from frontend:
{"$or": [ {"lastName":"ibrahim"}, {"$and": [ {"firstName":"mostafa"}, {"birthDate": {"$gt":"1990-01-01"}} ] } ]}
For a quick start seethis Medium postordev.to postor seethis demo example on Github.
Seedocumentation website for details about how to get started.
For spring-boot 3.x:
<dependency> <groupId>com.github.mhewedy</groupId> <artifactId>spring-data-jpa-mongodb-expressions</artifactId> <version>0.1.10</version></dependency>
For spring-boot 2.x:
<dependency> <groupId>com.github.mhewedy</groupId> <artifactId>spring-data-jpa-mongodb-expressions</artifactId> <version>0.0.8</version></dependency>
Special thanks toRashad Saif andHamada Elnoby for helping in the design, inspring with ideas, and for doing code review.
This repo has been mentioned inspring.io weekly news.
About
Use the MongoDB query language to query your relational database, typically from frontend.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
