An open API service indexing awesome lists of open source software.

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.

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);
```