由于数据量巨大,查询到内存操作完之后保存非常耗时,改为在数据库中直接操作
- 查询语句
Query query = Query.query(Criteria.where("xxx").is(xxx));
- 更新语句
Update update = new Update().set("xxx", xxx);
- 保存更新
UpdateResult updateResult = mongoTemplate.updateMulti(query, update, xxx.class);
- 更新数据判断
if (updateResult.getModifiedCount() != 0) {
// 确认更新了之后的操作
}