Bulk updates are supported from spring-data-mongodb from 1.9.0.RELEASE.
BulkOperations ops = template.bulkOps(BulkMode.UNORDERED, Match.class);
for (User user : users) {
Update update = new Update();
...
ops.updateOne(query(where("id").is(user.getId())), update);
}
ops.execute();
mongoTemplate has the function called void save(Object objectToSave); I want to insert/update the whole record but not some particular fields. Is there any way or function that I can void the Update class?
Maybe something like this..?
BulkOperations ops = template.bulkOps(BulkMode.UNORDERED, Match.class);
for (User user : users) {
...
ops.save(query(where("id").is(user.getId())), user);
}
ops.execute();