Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhewedy/spring-data-jpa-mongodb-expressions
Use the MongoDB query language to query your relational database, typically from frontend.
https://github.com/mhewedy/spring-data-jpa-mongodb-expressions
hibernate java jpa mongodb spring spring-boot spring-data-jpa
Last synced: 5 days ago
JSON representation
Use the MongoDB query language to query your relational database, typically from frontend.
- Host: GitHub
- URL: https://github.com/mhewedy/spring-data-jpa-mongodb-expressions
- Owner: mhewedy
- License: apache-2.0
- Created: 2021-02-13T11:37:59.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T09:50:32.000Z (6 months ago)
- Last Synced: 2024-12-30T01:14:35.479Z (12 days ago)
- Topics: hibernate, java, jpa, mongodb, spring, spring-boot, spring-data-jpa
- Language: Java
- Homepage: https://mhewedy.github.io/spring-data-jpa-mongodb-expressions/
- Size: 1.46 MB
- Stars: 97
- Watchers: 10
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java-zh - Spring Data JPA MongoDB Expressions - 允许您使用MongoDB查询语言来查询您的关系数据库。 (项目 / 数据库)
- awesome-java - Spring Data JPA MongoDB Expressions - Allows you to use MongoDB query language to query your relational database. (Projects / Database)
README
# Spring Data JPA MongoDB Expressions
[![Java CI with Maven](https://github.com/mhewedy/spring-data-jpa-mongodb-expressions/actions/workflows/maven.yml/badge.svg)](https://github.com/mhewedy/spring-data-jpa-mongodb-expressions/actions/workflows/maven.yml)
[![codecov](https://codecov.io/gh/mhewedy/spring-data-jpa-mongodb-expressions/branch/master/graph/badge.svg?token=3BR9MGYVC8)](https://codecov.io/gh/mhewedy/spring-data-jpa-mongodb-expressions)
[![javadoc](https://javadoc.io/badge2/com.github.mhewedy/spring-data-jpa-mongodb-expressions/javadoc.svg)](https://javadoc.io/doc/com.github.mhewedy/spring-data-jpa-mongodb-expressions)
[![Join the chat at https://gitter.im/spring-data-jpa-mongodb-expressions/community](https://badges.gitter.im/spring-data-jpa-mongodb-expressions/community.svg)](https://gitter.im/spring-data-jpa-mongodb-expressions/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Use%20the%20MongoDB%20query%20syntax%20to%20query%20your%20relational%20database&url=https://github.com/mhewedy/spring-data-jpa-mongodb-expressions&via=Github&hashtags=java,springboot,mongodb,jpa,hibernate)### How it works:
1. Customize JPA Repository base class:
```java
@SpringBootApplication
@EnableJpaRepositories(repositoryBaseClass = ExpressionsRepositoryImpl.class)
public class Application { … }
```
2. Change your repository to extend `ExpressionsRepository`:
```java
@Repository
public interface EmployeeRepository extends ExpressionsRepository {
}
```
3. Build the controller/service:
```java
@PostMapping("/search")
public ResponseEntity> search(@RequestBody Expressions expressions, Pageable pageable) {return ok().body(
employeeRepository.findAll(expressions, pageable).map(employeeMapper::toDto)
);
}
```
4. Send [Mongodb query in JSON](https://mhewedy.github.io/spring-data-jpa-mongodb-expressions/#_how_to_build_the_expressions) from frontend:
```json
{
"$or": [
{"lastName": "ibrahim"},
{
"$and": [
{"firstName": "mostafa"},
{"birthDate": {"$gt": "1990-01-01"}}
]
}
]
}
```### Learn more
For a quick start see [this Medium post](https://mohewedy.medium.com/using-mongodb-query-syntax-to-query-relational-database-in-java-57701f0b0f0)
or [dev.to post](https://dev.to/mhewedy/using-mongodb-query-syntax-to-query-relational-database-in-java-49hf)
or see [this demo example on Github](https://github.com/springexamples/spring-data-jpa-mongodb-expressions-demo).See [documentation website](https://mhewedy.github.io/spring-data-jpa-mongodb-expressions/) for details about how to get started.
### Install:
For spring-boot 3.x:
```xmlcom.github.mhewedy
spring-data-jpa-mongodb-expressions
0.1.3```
For spring-boot 2.x:```xml
com.github.mhewedy
spring-data-jpa-mongodb-expressions
0.0.8```
#### 🎖 Special Thanks
Special thanks to [Rashad Saif](https://github.com/rashadsaif) and [Hamada Elnoby](https://github.com/hamadaelnopy) for helping in the design, inspring with ideas, and for doing code review.
#### In the News
This repo has been mentioned in [spring.io](http://spring.io/blog/2021/07/06/this-week-in-spring-july-6th-2021) weekly news.