Spring Data MongoDB and Bulk Update

后端 未结 3 582
[愿得一人]
[愿得一人] 2020-12-02 00:09

I am using Spring Data MongoDB and would like to perform a Bulk Update just like the one described here: http://docs.mongodb.org/manual/reference/method/Bulk.find.update/#Bu

3条回答
  •  醉酒成梦
    2020-12-02 00:45

    Bulk updates are supported from spring-data-mongodb 1.9.0.RELEASE. Here is a sample:

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

提交回复
热议问题