Interface ReactiveBulkOperations


public interface ReactiveBulkOperations
Bulk operations for insert/update/remove actions on a collection. Bulk operations are available since MongoDB 2.6 and make use of low level bulk commands on the protocol level. This interface defines a fluent API to add multiple single operations or list of similar operations in sequence which can then eventually be executed by calling execute().
 ReactiveMongoOperations ops = …;

 ops.bulkOps(BulkMode.UNORDERED, Person.class)
                                .insert(newPerson)
                                .updateOne(where("firstname").is("Joe"), Update.update("lastname", "Doe"))
                                .execute();
 

Bulk operations are issued as one batch that pulls together all insert, update, and delete operations. Operations that require individual operation results such as optimistic locking (using @Version) are not supported and the version field remains not populated.

Since:
4.1
Author:
Christoph Strobl
  • Method Details

    • insert

      ReactiveBulkOperations insert(Object documents)
      Add a single insert to the bulk operation.
      Parameters:
      documents - the document to insert, must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the insert added, will never be null.
    • insert

      ReactiveBulkOperations insert(List<? extends Object> documents)
      Add a list of inserts to the bulk operation.
      Parameters:
      documents - List of documents to insert, must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the insert added, will never be null.
    • updateOne

      ReactiveBulkOperations updateOne(Query query, UpdateDefinition update)
      Add a single update to the bulk operation. For the update request, only the first matching document is updated.
      Parameters:
      query - update criteria, must not be null.
      update - UpdateDefinition operation to perform, must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the update added, will never be null.
    • updateMulti

      ReactiveBulkOperations updateMulti(Query query, UpdateDefinition update)
      Add a single update to the bulk operation. For the update request, all matching documents are updated.
      Parameters:
      query - Update criteria.
      update - Update operation to perform.
      Returns:
      the current ReactiveBulkOperations instance with the update added, will never be null.
    • upsert

      Add a single upsert to the bulk operation. An upsert is an update if the set of matching documents is not empty, else an insert.
      Parameters:
      query - Update criteria.
      update - Update operation to perform.
      Returns:
      the current ReactiveBulkOperations instance with the update added, will never be null.
    • remove

      ReactiveBulkOperations remove(Query remove)
      Add a single remove operation to the bulk operation.
      Parameters:
      remove - the Query to select the documents to be removed, must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the removal added, will never be null.
    • remove

      ReactiveBulkOperations remove(List<Query> removes)
      Add a list of remove operations to the bulk operation.
      Parameters:
      removes - the remove operations to perform, must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the removal added, will never be null.
    • replaceOne

      default ReactiveBulkOperations replaceOne(Query query, Object replacement)
      Add a single replace operation to the bulk operation.
      Parameters:
      query - Update criteria.
      replacement - the replacement document. Must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the replace added, will never be null.
    • replaceOne

      ReactiveBulkOperations replaceOne(Query query, Object replacement, FindAndReplaceOptions options)
      Add a single replace operation to the bulk operation.
      Parameters:
      query - Update criteria.
      replacement - the replacement document. Must not be null.
      options - the FindAndModifyOptions holding additional information. Must not be null.
      Returns:
      the current ReactiveBulkOperations instance with the replace added, will never be null.
    • execute

      reactor.core.publisher.Mono<com.mongodb.bulk.BulkWriteResult> execute()
      Execute all bulk operations using the default write concern.
      Returns:
      a Mono emitting the result of the bulk operation providing counters for inserts/updates etc.