Skip to content

Add support for Bulk Write into multiple collections. #5087

@christophstrobl

Description

@christophstrobl

See: https://www.mongodb.com/docs/manual/core/bulk-write-operations/#mongo.bulkwrite--

MongoDB 8.0 introduced BulkWrite across multiple collections.

We should use the opportunity to revisit the current approach via BulkOperations and decouple setting up the bulk instructions from the actual execution while allowing users targeting a single collection to use the same API.

Bulk bulk = Bulk.create(builder -> builder
        .inCollection(Person.class, spec -> spec
                .insert(person1)
                .insert(person2)
                .upsert(where("_id").is("..."), new Update().set("firstname", "...")))
        .inCollection(User.class, spec -> spec.insert(new User("..."))));

BulkWriteResult result = template.bulkWrite(bulk, BulkWriteOptions.ordered());

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: planningAn issue we'd like to consider when planning our next releasetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions