Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void bulkUpdate(List<Map<String, Object>> users) {
- BulkOperations bulkOperations = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, getCollectionName());
- for (Map<String, Object> user : users) {
- Query query = new Query(Criteria.where("_id").is((String) user.get("_id")));
- bulkOperations.replaceOne(query, user, FindAndReplaceOptions.options().upsert());
- }
- bulkOperations.execute();
- }
- //pom.xml
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.1.5.RELEASE</version>
- </parent>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-releasetrain</artifactId>
- <version>Moore-RELEASE</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
Add Comment
Please, Sign In to add comment