@@ -18,21 +18,21 @@ MongoDB Java Driver.
18
18
19
19
To perform a single create, replace, update, or delete operation, you can use
20
20
the corresponding method. For example, to insert one document and replace one
21
- document, you can use the ``insertOne()`` and ``replaceOne()`` methods. The
22
- ``MongoClient`` makes a call to the database for each operation. You can reduce
23
- the number of calls to one by using bulk write operations.
21
+ document, you can use the ``insertOne()`` and ``replaceOne()`` methods. In this
22
+ case, the ``MongoClient`` makes a call to the database for each operation.
23
+ You can reduce the number of calls to one by using bulk write operations.
24
24
25
25
You can perform bulk write operations by using the bulk write API in the
26
- {+driver-short+} driver to perform multiple data changes in one call. You can
26
+ {+driver-short+} to perform multiple data changes in one call. You can
27
27
perform bulk operations at the following levels:
28
28
29
29
- :ref:`Collection Level <java-sync-coll-bulk-write>`: You can use the
30
- ``MongoCollection.bulkWrite()`` API to perform bulk write operations on a
31
- collection.
30
+ ``MongoCollection.bulkWrite()`` method to perform bulk write operations on a
31
+ single collection.
32
32
33
- - :ref:`Client Level <java-sync-client-bulk-write>`: In {+mdb-server+} version
34
- 8.0 or later, you can use the ``MongoClient.bulkWrite()`` API to perform bulk write
35
- operations on multiple collections and databases in the same cluster.
33
+ - :ref:`Client Level <java-sync-client-bulk-write>`: When running {+mdb-server+}
34
+ version 8.0 or later, you can use the ``MongoClient.bulkWrite()`` method to perform
35
+ bulk write operations on multiple collections and databases in the same cluster.
36
36
37
37
.. _java-sync-coll-bulk-write:
38
38
@@ -320,11 +320,14 @@ instance of ``InsertOneModel`` represents an operation to insert one document.
320
320
321
321
Similarly, the ``MongoClient.bulkWrite()`` method takes a
322
322
list of ``ClientNamespacedWriteModel`` instances to represent different write operations.
323
- However, it is not necessary to specify the subclass that represents the corresponding
324
- write operation. Instead, the ``ClientNamespacedWriteModel`` object contains different
325
- methods to represent different write operations, such as ``ClientNamespacedWriteModel.insertOne()`` or
323
+ Instead of selecting a specific subclass for each write operation, the
324
+ ``ClientNamespacedWriteModel`` object contains different methods to represent
325
+ write operations, such as ``ClientNamespacedWriteModel.insertOne()`` or
326
326
``ClientNamespacedWriteModel.updateOne()``.
327
327
328
+ ``ClientNamespacedWriteModel`` contains the methods ``insertOne()``, ``updateOne()``,
329
+ ``updateMany()``, ``replaceOne()``, ``deleteOne()``, and ``deleteMany()``.
330
+
328
331
These methods take a ``MongoNamespace`` object that defines which
329
332
database and collection to write to, and a ``Document`` object that defines
330
333
information about the write operation. Some methods, such as ``updateOne()`` and
@@ -416,8 +419,8 @@ By default, the driver performs write operations in the order that you specify t
416
419
an error occurs, or until they execute successfully. However, you can pass
417
420
``false`` to the ``ordered()`` method on the ``ClientBulkWriteOptions``
418
421
interface to perform write operations in an unordered way. When using the unordered
419
- option, an error-producing operation does not block execution of other bulk
420
- write operations.
422
+ option, an error-producing operation does not block execution of other write
423
+ operations in the call to the ``bulkWrite()`` method .
421
424
422
425
The following code sets the ``ordered()`` method on an
423
426
instance of ``ClientBulkWriteOptions`` and performs a bulk write operation to
@@ -431,7 +434,7 @@ insert multiple documents.
431
434
432
435
List<ClientNamespacedWriteModel> bulkOperations = new ArrayList<>();
433
436
434
- bulkOperations.add(ClientNamespacedWriteModel.insertOne(namespace, new Document("_id", 1).append("name", "Rudra Suraj)));
437
+ bulkOperations.add(ClientNamespacedWriteModel.insertOne(namespace, new Document("_id", 1).append("name", "Rudra Suraj" )));
435
438
436
439
// Causes a duplicate key error
437
440
bulkOperations.add(ClientNamespacedWriteModel.insertOne(namespace, new Document("_id", 1).append("name", "Mario Bianchi")));
0 commit comments