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());
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
BulkOperationsand decouple setting up the bulk instructions from the actual execution while allowing users targeting a single collection to use the same API.