https://github.com/lkqm/spring-data-mongodb-extends
Useful spring-data-mongodb extends, such as partial update method, generic crud service.
https://github.com/lkqm/spring-data-mongodb-extends
Last synced: about 2 months ago
JSON representation
Useful spring-data-mongodb extends, such as partial update method, generic crud service.
- Host: GitHub
- URL: https://github.com/lkqm/spring-data-mongodb-extends
- Owner: lkqm
- Created: 2020-12-16T08:44:25.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-02T07:54:13.000Z (over 3 years ago)
- Last Synced: 2023-06-30T20:37:23.588Z (almost 2 years ago)
- Language: Java
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-data-mongodb-extends
Useful spring-data-mongodb extends, such as partial update method, generic crud service.给力的spring-data-mongodb扩展, 例如部分更新方法、通用的curd服务类.
```
com.github.lkqm
spring-data-mongodb-extends
0.1.0```
## Features
- MongoRepositoryPlus: Partial update entity methods.
- BaseService: Generic crud methods.## Methods
- BaseService
```
save(entity)
update(entity)
deleteById(id)
deleteById(ids)
findById(id)
findById(ids)
count()
```
- MongoRepositoryPlus
```
update(entity)
update(query, entity)
count(query)
findOne(query)
findAll(query)
findAll(query, pageable)
mongoOperations()
```## How to use?
```
// 1. Enable MongoRepositoryPlusImpl
@SpringBootApplication
@EnableMongoRepositories(repositoryBaseClass = MongoRepositoryPlusImpl.class)
public class Main {public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}}
// 2. Implements MongoRepositoryPlus
public interface UserRepository extends MongoRepositoryPlus {
/*
default List listUsers() {
return mongoOperations().findAll();
}
*/
}// 3. Use repository
userRepository.update(user);
```