@@ -22,6 +22,9 @@ import com.mongodb.reactivestreams.client.{ MongoCluster => JMongoCluster }
22
22
import org .bson .codecs .configuration .CodecRegistry
23
23
import org .mongodb .scala .bson .DefaultHelper .DefaultsTo
24
24
import org .mongodb .scala .bson .conversions .Bson
25
+ import org .mongodb .scala .model .bulk .ClientNamespacedUpdateManyModel
26
+ import org .mongodb .scala .model .bulk .ClientNamespacedDeleteManyModel
27
+ import org .mongodb .scala .model .bulk .{ ClientBulkWriteOptions , ClientBulkWriteResult , ClientNamespacedWriteModel }
25
28
26
29
import scala .collection .JavaConverters ._
27
30
import scala .concurrent .duration .{ Duration , MILLISECONDS }
@@ -290,4 +293,124 @@ class MongoCluster(private val wrapped: JMongoCluster) {
290
293
)(implicit e : C DefaultsTo Document , ct : ClassTag [C ]): ChangeStreamObservable [C ] =
291
294
ChangeStreamObservable (wrapped.watch(clientSession, pipeline.asJava, ct))
292
295
296
+ /**
297
+ * Executes a client-level bulk write operation.
298
+ * This method is functionally equivalent to `bulkWrite(List, ClientBulkWriteOptions)`
299
+ * with the [[ClientBulkWriteOptions.clientBulkWriteOptions default options ]].
300
+ *
301
+ * This operation supports retryable writes.
302
+ * Depending on the number of `models`, encoded size of `models`, and the size limits in effect,
303
+ * executing this operation may require multiple `bulkWrite` commands.
304
+ * The eligibility for retries is determined per each `bulkWrite` command:
305
+ * [[ClientNamespacedUpdateManyModel ]], [[ClientNamespacedDeleteManyModel ]] in a command render it non-retryable.
306
+ *
307
+ * This operation is not supported by MongoDB Atlas Serverless instances.
308
+ *
309
+ * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite ]]
310
+ * @param models The [[ClientNamespacedWriteModel ]] individual write operations.
311
+ * @return The [[SingleObservable ]] signalling at most one element [[ClientBulkWriteResult ]] if the operation is successful,
312
+ * or the following errors:
313
+ * - [[ClientBulkWriteException ]]: If and only if the operation is unsuccessful or partially unsuccessful,
314
+ * and there is at least one of the following pieces of information to report:
315
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors ]],
316
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors ]],
317
+ * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult ]].
318
+ * - [[MongoException ]]: Only if the operation is unsuccessful.
319
+ * @since 5.4
320
+ * @note Requires MongoDB 8.0 or greater.
321
+ */
322
+ def bulkWrite (models : List [_ <: ClientNamespacedWriteModel ]): SingleObservable [ClientBulkWriteResult ] =
323
+ wrapped.bulkWrite(models.asJava)
324
+
325
+ /**
326
+ * Executes a client-level bulk write operation.
327
+ *
328
+ * This operation supports retryable writes.
329
+ * Depending on the number of `models`, encoded size of `models`, and the size limits in effect,
330
+ * executing this operation may require multiple `bulkWrite` commands.
331
+ * The eligibility for retries is determined per each `bulkWrite` command:
332
+ * [[ClientNamespacedUpdateManyModel ]], [[ClientNamespacedDeleteManyModel ]] in a command render it non-retryable.
333
+ *
334
+ * This operation is not supported by MongoDB Atlas Serverless instances.
335
+ *
336
+ * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite ]]
337
+ * @param models The [[ClientNamespacedWriteModel ]] individual write operations.
338
+ * @param options The options.
339
+ * @return The [[SingleObservable ]] signalling at most one element [[ClientBulkWriteResult ]] if the operation is successful,
340
+ * or the following errors:
341
+ * - [[ClientBulkWriteException ]]: If and only if the operation is unsuccessful or partially unsuccessful,
342
+ * and there is at least one of the following pieces of information to report:
343
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors ]],
344
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors ]],
345
+ * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult ]].
346
+ * - [[MongoException ]]: Only if the operation is unsuccessful.
347
+ * @since 5.4
348
+ * @note Requires MongoDB 8.0 or greater.
349
+ */
350
+ def bulkWrite (
351
+ models : List [_ <: ClientNamespacedWriteModel ],
352
+ options : ClientBulkWriteOptions
353
+ ): SingleObservable [ClientBulkWriteResult ] = wrapped.bulkWrite(models.asJava, options)
354
+
355
+ /**
356
+ * Executes a client-level bulk write operation.
357
+ * This method is functionally equivalent to `bulkWrite(ClientSession, List, ClientBulkWriteOptions)`
358
+ * with the [[ClientBulkWriteOptions.clientBulkWriteOptions default options ]].
359
+ *
360
+ * This operation supports retryable writes.
361
+ * Depending on the number of `models`, encoded size of `models`, and the size limits in effect,
362
+ * executing this operation may require multiple `bulkWrite` commands.
363
+ * The eligibility for retries is determined per each `bulkWrite` command:
364
+ * [[ClientNamespacedUpdateManyModel ]], [[ClientNamespacedDeleteManyModel ]] in a command render it non-retryable.
365
+ *
366
+ * This operation is not supported by MongoDB Atlas Serverless instances.
367
+ *
368
+ * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite ]]
369
+ * @param clientSession [[ClientSession client session ]] with which to associate this operation.
370
+ * @param models The [[ClientNamespacedWriteModel ]] individual write operations.
371
+ * @return The [[SingleObservable ]] signalling at most one element [[ClientBulkWriteResult ]] if the operation is successful,
372
+ * or the following errors:
373
+ * - [[ClientBulkWriteException ]]: If and only if the operation is unsuccessful or partially unsuccessful,
374
+ * and there is at least one of the following pieces of information to report:
375
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors ]],
376
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors ]],
377
+ * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult ]].
378
+ * - [[MongoException ]]: Only if the operation is unsuccessful.
379
+ * @since 5.4
380
+ * @note Requires MongoDB 8.0 or greater.
381
+ */
382
+ def bulkWrite (
383
+ clientSession : ClientSession ,
384
+ models : List [_ <: ClientNamespacedWriteModel ]
385
+ ): SingleObservable [ClientBulkWriteResult ] = wrapped.bulkWrite(clientSession, models.asJava)
386
+
387
+ /**
388
+ * Executes a client-level bulk write operation.
389
+ *
390
+ * This operation supports retryable writes.
391
+ * Depending on the number of `models`, encoded size of `models`, and the size limits in effect,
392
+ * executing this operation may require multiple `bulkWrite` commands.
393
+ * The eligibility for retries is determined per each `bulkWrite` command:
394
+ * [[ClientNamespacedUpdateManyModel ]], [[ClientNamespacedDeleteManyModel ]] in a command render it non-retryable.
395
+ *
396
+ * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite ]]
397
+ * @param clientSession The [[ClientSession client session ]] with which to associate this operation.
398
+ * @param models The [[ClientNamespacedWriteModel ]] individual write operations.
399
+ * @param options The options.
400
+ * @return The [[SingleObservable ]] signalling at most one element [[ClientBulkWriteResult ]] if the operation is successful,
401
+ * or the following errors:
402
+ * - [[ClientBulkWriteException ]]: If and only if the operation is unsuccessful or partially unsuccessful,
403
+ * and there is at least one of the following pieces of information to report:
404
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors ]],
405
+ * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors ]],
406
+ * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult ]].
407
+ * - [[MongoException ]]: Only if the operation is unsuccessful.
408
+ * @since 5.4
409
+ * @note Requires MongoDB 8.0 or greater.
410
+ */
411
+ def bulkWrite (
412
+ clientSession : ClientSession ,
413
+ models : List [_ <: ClientNamespacedWriteModel ],
414
+ options : ClientBulkWriteOptions
415
+ ): SingleObservable [ClientBulkWriteResult ] = wrapped.bulkWrite(clientSession, models.asJava, options)
293
416
}
0 commit comments