From 3f44f40e950a6eeb586b8404edba64e85412b682 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Fri, 3 Jan 2025 13:07:12 -0800 Subject: [PATCH 1/5] Add Scala Bulk Write API. JAVA-5531 --- .../scala/syncadapter/SyncMongoCluster.scala | 21 +- .../org/mongodb/scala/MongoCluster.scala | 121 +++++++++ .../mongodb/scala/model/bulk/package.scala | 244 ++++++++++++++++++ .../org/mongodb/scala/MongoClientSpec.scala | 33 +++ .../org/mongodb/scala/ScalaPackageSpec.scala | 1 - .../scala/model/bulk/BulkModelSpec.scala | 111 ++++++++ 6 files changed, 513 insertions(+), 18 deletions(-) create mode 100644 driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala create mode 100644 driver-scala/src/test/scala/org/mongodb/scala/model/bulk/BulkModelSpec.scala diff --git a/driver-scala/src/integration/scala/org/mongodb/scala/syncadapter/SyncMongoCluster.scala b/driver-scala/src/integration/scala/org/mongodb/scala/syncadapter/SyncMongoCluster.scala index 972831f197f..439188e3792 100644 --- a/driver-scala/src/integration/scala/org/mongodb/scala/syncadapter/SyncMongoCluster.scala +++ b/driver-scala/src/integration/scala/org/mongodb/scala/syncadapter/SyncMongoCluster.scala @@ -1,6 +1,5 @@ package org.mongodb.scala.syncadapter -import com.mongodb.assertions.Assertions import com.mongodb.client.model.bulk.{ ClientBulkWriteOptions, ClientBulkWriteResult, ClientNamespacedWriteModel } import com.mongodb.{ ClientSessionOptions, ReadConcern, ReadPreference, WriteConcern } import com.mongodb.client.{ ClientSession, MongoCluster => JMongoCluster, MongoDatabase => JMongoDatabase } @@ -129,33 +128,21 @@ class SyncMongoCluster(wrapped: MongoCluster) extends JMongoCluster { override def bulkWrite( models: util.List[_ <: ClientNamespacedWriteModel] - ): ClientBulkWriteResult = { - org.junit.Assume.assumeTrue("TODO-JAVA-5531 implement", java.lang.Boolean.parseBoolean(toString)) - throw Assertions.fail("TODO-JAVA-5531 implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(models.asScala.toList).toFuture().get() override def bulkWrite( models: util.List[_ <: ClientNamespacedWriteModel], options: ClientBulkWriteOptions - ): ClientBulkWriteResult = { - org.junit.Assume.assumeTrue("TODO-JAVA-5531 implement", java.lang.Boolean.parseBoolean(toString)) - throw Assertions.fail("TODO-JAVA-5531 implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(models.asScala.toList, options).toFuture().get() override def bulkWrite( clientSession: ClientSession, models: util.List[_ <: ClientNamespacedWriteModel] - ): ClientBulkWriteResult = { - org.junit.Assume.assumeTrue("TODO-JAVA-5531 implement", java.lang.Boolean.parseBoolean(toString)) - throw Assertions.fail("TODO-JAVA-5531 implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(unwrap(clientSession), models.asScala.toList).toFuture().get() override def bulkWrite( clientSession: ClientSession, models: util.List[_ <: ClientNamespacedWriteModel], options: ClientBulkWriteOptions - ): ClientBulkWriteResult = { - org.junit.Assume.assumeTrue("TODO-JAVA-5531 implement", java.lang.Boolean.parseBoolean(toString)) - throw Assertions.fail("TODO-JAVA-5531 implement") - } + ): ClientBulkWriteResult = wrapped.bulkWrite(unwrap(clientSession), models.asScala.toList, options).toFuture().get() } diff --git a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala index a7352d5ac41..01a0a56f56a 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala @@ -19,9 +19,14 @@ package org.mongodb.scala import com.mongodb.annotations.{ Alpha, Reason } import com.mongodb.{ ReadConcern, ReadPreference, WriteConcern } import com.mongodb.reactivestreams.client.{ MongoCluster => JMongoCluster } +import com.mongodb.ClientBulkWriteException import org.bson.codecs.configuration.CodecRegistry import org.mongodb.scala.bson.DefaultHelper.DefaultsTo import org.mongodb.scala.bson.conversions.Bson +import org.mongodb.scala.model.bulk.ClientNamespacedUpdateManyModel +import org.mongodb.scala.model.bulk.ClientNamespacedDeleteManyModel +import org.mongodb.scala.model.bulk.ClientNamespacedWriteModel +import org.mongodb.scala.model.bulk.{ ClientBulkWriteOptions, ClientBulkWriteResult, ClientNamespacedWriteModel } import scala.collection.JavaConverters._ import scala.concurrent.duration.{ Duration, MILLISECONDS } @@ -290,4 +295,120 @@ class MongoCluster(private val wrapped: JMongoCluster) { )(implicit e: C DefaultsTo Document, ct: ClassTag[C]): ChangeStreamObservable[C] = ChangeStreamObservable(wrapped.watch(clientSession, pipeline.asJava, ct)) + /** + * Executes a client-level bulk write operation. + * This method is functionally equivalent to `bulkWrite(List, ClientBulkWriteOptions)` + * with the [[ClientBulkWriteOptions.clientBulkWriteOptions default options]]. + * + * This operation supports retryable writes. + * Depending on the number of `models`, encoded size of `models`, and the size limits in effect, + * executing this operation may require multiple `bulkWrite` commands. + * The eligibility for retries is determined per each `bulkWrite` command: + * [[ClientNamespacedUpdateManyModel]], [[ClientNamespacedDeleteManyModel]] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite]] + * @param models The [[ClientNamespacedWriteModel]] individual write operations. + * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, + * or the following errors: + * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: + * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], + * [[ClientBulkWriteException.getPartialResult]]. + * - [[MongoException]]: Only if the operation is unsuccessful. + * @since 5.3 + * @note Requires MongoDB 8.0 or greater. + */ + def bulkWrite(models: List[_ <: ClientNamespacedWriteModel]): SingleObservable[ClientBulkWriteResult] = + wrapped.bulkWrite(models.asJava) + + /** + * Executes a client-level bulk write operation. + * + * This operation supports retryable writes. + * Depending on the number of `models`, encoded size of `models`, and the size limits in effect, + * executing this operation may require multiple `bulkWrite` commands. + * The eligibility for retries is determined per each `bulkWrite` command: + * [[ClientNamespacedUpdateManyModel]], [[ClientNamespacedDeleteManyModel]] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite]] + * @param models The [[ClientNamespacedWriteModel]] individual write operations. + * @param options The options. + * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, + * or the following errors: + * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: + * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], + * [[ClientBulkWriteException.getPartialResult]]. + * - [[MongoException]]: Only if the operation is unsuccessful. + * @since 5.3 + * @note Requires MongoDB 8.0 or greater. + */ + def bulkWrite( + models: List[_ <: ClientNamespacedWriteModel], + options: ClientBulkWriteOptions + ): SingleObservable[ClientBulkWriteResult] = wrapped.bulkWrite(models.asJava, options) + + /** + * Executes a client-level bulk write operation. + * This method is functionally equivalent to `bulkWrite(ClientSession, List, ClientBulkWriteOptions)` + * with the [[ClientBulkWriteOptions.clientBulkWriteOptions default options]]. + * + * This operation supports retryable writes. + * Depending on the number of `models`, encoded size of `models`, and the size limits in effect, + * executing this operation may require multiple `bulkWrite` commands. + * The eligibility for retries is determined per each `bulkWrite` command: + * [[ClientNamespacedUpdateManyModel]], [[ClientNamespacedDeleteManyModel]] in a command render it non-retryable. + * + * This operation is not supported by MongoDB Atlas Serverless instances. + * + * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite]] + * @param clientSession The {@linkplain ClientSession client session} with which to associate this operation. + * @param models The [[ClientNamespacedWriteModel]] individual write operations. + * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, + * or the following errors: + * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: + * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], + * [[ClientBulkWriteException.getPartialResult]]. + * - [[MongoException]]: Only if the operation is unsuccessful. + * @since 5.3 + * @note Requires MongoDB 8.0 or greater. + */ + def bulkWrite( + clientSession: ClientSession, + models: List[_ <: ClientNamespacedWriteModel] + ): SingleObservable[ClientBulkWriteResult] = wrapped.bulkWrite(clientSession, models.asJava) + + /** + * Executes a client-level bulk write operation. + * + * This operation supports retryable writes. + * Depending on the number of `models`, encoded size of `models`, and the size limits in effect, + * executing this operation may require multiple `bulkWrite` commands. + * The eligibility for retries is determined per each `bulkWrite` command: + * [[ClientNamespacedUpdateManyModel]], [[ClientNamespacedDeleteManyModel]] in a command render it non-retryable. + * + * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite]] + * @param clientSession The [[ClientSession client session]] with which to associate this operation. + * @param models The [[ClientNamespacedWriteModel]] individual write operations. + * @param options The options. + * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, + * or the following errors: + * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * and there is at least one of the following pieces of information to report: + * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], + * [[ClientBulkWriteException.getPartialResult]]. + * - [[MongoException]]: Only if the operation is unsuccessful. + * @since 5.3 + * @note Requires MongoDB 8.0 or greater. + */ + def bulkWrite( + clientSession: ClientSession, + models: List[_ <: ClientNamespacedWriteModel], + options: ClientBulkWriteOptions + ): SingleObservable[ClientBulkWriteResult] = wrapped.bulkWrite(clientSession, models.asJava, options) } diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala new file mode 100644 index 00000000000..fcc99533f98 --- /dev/null +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala @@ -0,0 +1,244 @@ +package org.mongodb.scala.model + +import org.mongodb.scala.MongoNamespace +import org.mongodb.scala.bson.conversions.Bson + +import scala.collection.JavaConverters._ + +/** + * Models, options, results for the client-level bulk write operation. + * + * @since 5.3 + */ +package object bulk { + + /** + * A combination of an individual write operation and a [[MongoNamespace]] + * the operation is targeted at. + * + * @since 5.3 + */ + type ClientNamespacedWriteModel = com.mongodb.client.model.bulk.ClientNamespacedWriteModel + + /** + * A model for inserting a document. + * + * @since 5.3 + */ + type ClientNamespacedInsertOneModel = com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel + + /** + * A model for updating at most one document matching a filter. + * + * @since 5.3 + */ + type ClientNamespacedUpdateOneModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel + + /** + * A model for updating all documents matching a filter. + * + * @since 5.3 + */ + type ClientNamespacedUpdateManyModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel + + /** + * A model for replacing at most one document matching a filter. + * + * @since 5.3 + */ + type ClientNamespacedReplaceOneModel = com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel + + /** + * A model for deleting at most one document matching a filter. + * + * @since 5.3 + */ + type ClientNamespacedDeleteOneModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel + + /** + * A model for deleting all documents matching a filter. + * + * @since 5.3 + */ + type ClientNamespacedDeleteManyModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel + + object ClientNamespacedWriteModel { + + def insertOne[TDocument](namespace: MongoNamespace, document: TDocument): ClientNamespacedInsertOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.insertOne(namespace, document) + + def updateOne(namespace: MongoNamespace, filter: Bson, update: Bson): ClientNamespacedUpdateOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateOne(namespace, filter, update) + + def updateOne( + namespace: MongoNamespace, + filter: Bson, + update: Bson, + options: ClientUpdateOneOptions + ): ClientNamespacedUpdateOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateOne(namespace, filter, update, options) + + def updateOne( + namespace: MongoNamespace, + filter: Bson, + updatePipeline: Iterable[_ <: Bson] + ): ClientNamespacedUpdateOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateOne(namespace, filter, updatePipeline.asJava) + + def updateOne( + namespace: MongoNamespace, + filter: Bson, + updatePipeline: Iterable[_ <: Bson], + options: ClientUpdateOneOptions + ): ClientNamespacedUpdateOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateOne( + namespace, + filter, + updatePipeline.asJava, + options + ) + + def updateMany(namespace: MongoNamespace, filter: Bson, update: Bson): ClientNamespacedUpdateManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateMany(namespace, filter, update) + + def updateMany( + namespace: MongoNamespace, + filter: Bson, + update: Bson, + options: ClientUpdateManyOptions + ): ClientNamespacedUpdateManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateMany(namespace, filter, update, options) + + def updateMany( + namespace: MongoNamespace, + filter: Bson, + updatePipeline: Iterable[_ <: Bson] + ): ClientNamespacedUpdateManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateMany(namespace, filter, updatePipeline.asJava) + + def updateMany( + namespace: MongoNamespace, + filter: Bson, + updatePipeline: Iterable[_ <: Bson], + options: ClientUpdateManyOptions + ): ClientNamespacedUpdateManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.updateMany( + namespace, + filter, + updatePipeline.asJava, + options + ) + + def replaceOne[TDocument]( + namespace: MongoNamespace, + filter: Bson, + replacement: TDocument + ): ClientNamespacedReplaceOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.replaceOne(namespace, filter, replacement) + + def replaceOne[TDocument]( + namespace: MongoNamespace, + filter: Bson, + replacement: TDocument, + options: ClientReplaceOneOptions + ): ClientNamespacedReplaceOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.replaceOne(namespace, filter, replacement, options) + + def deleteOne(namespace: MongoNamespace, filter: Bson): ClientNamespacedDeleteOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.deleteOne(namespace, filter) + + def deleteOne( + namespace: MongoNamespace, + filter: Bson, + options: ClientDeleteOneOptions + ): ClientNamespacedDeleteOneModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.deleteOne(namespace, filter, options) + + def deleteMany(namespace: MongoNamespace, filter: Bson): ClientNamespacedDeleteManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.deleteMany(namespace, filter) + + def deleteMany( + namespace: MongoNamespace, + filter: Bson, + options: ClientDeleteManyOptions + ): ClientNamespacedDeleteManyModel = + com.mongodb.client.model.bulk.ClientNamespacedWriteModel.deleteMany(namespace, filter, options) + } + + /** + * The options to apply when executing a client-level bulk write operation. + * + * @since 5.3 + */ + type ClientBulkWriteOptions = com.mongodb.client.model.bulk.ClientBulkWriteOptions + + object ClientBulkWriteOptions { + def clientBulkWriteOptions(): ClientBulkWriteOptions = + com.mongodb.client.model.bulk.ClientBulkWriteOptions.clientBulkWriteOptions() + } + + /** + * The options to apply when updating a document. + * + * @since 5.3 + */ + type ClientUpdateOneOptions = com.mongodb.client.model.bulk.ClientUpdateOneOptions + + object ClientUpdateOneOptions { + def clientUpdateOneOptions(): ClientUpdateOneOptions = + com.mongodb.client.model.bulk.ClientUpdateOneOptions.clientUpdateOneOptions() + } + + /** + * The options to apply when updating documents. + * + * @since 5.3 + */ + type ClientUpdateManyOptions = com.mongodb.client.model.bulk.ClientUpdateManyOptions + + object ClientUpdateManyOptions { + def clientUpdateManyOptions(): ClientUpdateManyOptions = + com.mongodb.client.model.bulk.ClientUpdateManyOptions.clientUpdateManyOptions() + } + + /** + * The options to apply when replacing a document. + * + * @since 5.3 + */ + type ClientReplaceOneOptions = com.mongodb.client.model.bulk.ClientReplaceOneOptions + + object ClientReplaceOneOptions { + def clientReplaceOneOptions(): ClientReplaceOneOptions = + com.mongodb.client.model.bulk.ClientReplaceOneOptions.clientReplaceOneOptions() + } + + /** + * The options to apply when deleting a document. + * + * @since 5.3 + */ + type ClientDeleteOneOptions = com.mongodb.client.model.bulk.ClientDeleteOneOptions + + object ClientDeleteOneOptions { + def clientDeleteOneOptions(): ClientDeleteOneOptions = + com.mongodb.client.model.bulk.ClientDeleteOneOptions.clientDeleteOneOptions() + } + + /** + * The options to apply when deleting documents. + * + * @since 5.3 + */ + type ClientDeleteManyOptions = com.mongodb.client.model.bulk.ClientDeleteManyOptions + + object ClientDeleteManyOptions { + def clientDeleteManyOptions(): ClientDeleteManyOptions = + com.mongodb.client.model.bulk.ClientDeleteManyOptions.clientDeleteManyOptions() + } + + /** + * The result of a successful or partially successful client-level bulk write operation. + */ + type ClientBulkWriteResult = com.mongodb.client.model.bulk.ClientBulkWriteResult +} diff --git a/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala b/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala index 4e0189bfd5e..4f524ab79cb 100644 --- a/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala +++ b/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala @@ -19,6 +19,7 @@ package org.mongodb.scala import com.mongodb.reactivestreams.client.{ MongoClient => JMongoClient } import org.bson.BsonDocument import org.mockito.Mockito.verify +import org.mongodb.scala.model.bulk.{ ClientBulkWriteOptions, ClientBulkWriteResult, ClientNamespacedWriteModel } import org.scalatestplus.mockito.MockitoSugar import scala.collection.JavaConverters._ @@ -28,6 +29,7 @@ class MongoClientSpec extends BaseSpec with MockitoSugar { val wrapped = mock[JMongoClient] val clientSession = mock[ClientSession] val mongoClient = new MongoClient(wrapped) + val namespace = new MongoNamespace("db.coll") "MongoClient" should "have the same methods as the wrapped MongoClient" in { val wrapped = classOf[JMongoClient].getMethods.map(_.getName).toSet -- Seq("getSettings") @@ -104,6 +106,37 @@ class MongoClientSpec extends BaseSpec with MockitoSugar { verify(wrapped).watch(clientSession, pipeline.asJava, classOf[BsonDocument]) } + it should "call the underlying bulkWrite with models only" in { + val models = List(ClientNamespacedWriteModel.insertOne(namespace, Document("key" -> "value"))) + mongoClient.bulkWrite(models) shouldBe a[SingleObservable[ClientBulkWriteResult]] + verify(wrapped).bulkWrite(models.asJava) + } + + it should "call the underlying bulkWrite with models and options" in { + val models = List(ClientNamespacedWriteModel.insertOne(namespace, Document("key" -> "value"))) + val options = ClientBulkWriteOptions.clientBulkWriteOptions() + + mongoClient.bulkWrite(models, options) + + verify(wrapped).bulkWrite(models.asJava, options) + } + + it should "call the underlying bulkWrite with clientSession and models" in { + val models = List(ClientNamespacedWriteModel.insertOne(namespace, Document("key" -> "value"))) + + mongoClient.bulkWrite(clientSession, models) + + verify(wrapped).bulkWrite(clientSession, models.asJava) + } + + it should "call the underlying bulkWrite with clientSession, models, and options" in { + val models = List(ClientNamespacedWriteModel.insertOne(namespace, Document("key" -> "value"))) + val options = ClientBulkWriteOptions.clientBulkWriteOptions() + + mongoClient.bulkWrite(clientSession, models, options) + verify(wrapped).bulkWrite(clientSession, models.asJava, options) + } + it should "call the underlying getClusterDescription" in { mongoClient.getClusterDescription verify(wrapped).getClusterDescription diff --git a/driver-scala/src/test/scala/org/mongodb/scala/ScalaPackageSpec.scala b/driver-scala/src/test/scala/org/mongodb/scala/ScalaPackageSpec.scala index 3a91b8c3034..19b1140e8f7 100644 --- a/driver-scala/src/test/scala/org/mongodb/scala/ScalaPackageSpec.scala +++ b/driver-scala/src/test/scala/org/mongodb/scala/ScalaPackageSpec.scala @@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit import _root_.scala.concurrent.duration.Duration import com.mongodb.{ MongoCredential => JMongoCredential } import org.bson.BsonDocumentWrapper -import org.bson.codecs.DocumentCodec import org.mongodb.scala import org.mongodb.scala.MongoClient.DEFAULT_CODEC_REGISTRY import org.mongodb.scala.bson._ diff --git a/driver-scala/src/test/scala/org/mongodb/scala/model/bulk/BulkModelSpec.scala b/driver-scala/src/test/scala/org/mongodb/scala/model/bulk/BulkModelSpec.scala new file mode 100644 index 00000000000..f96ca2d96ee --- /dev/null +++ b/driver-scala/src/test/scala/org/mongodb/scala/model/bulk/BulkModelSpec.scala @@ -0,0 +1,111 @@ +package org.mongodb.scala.model.bulk + +import org.mongodb.scala.bson.Document +import org.mongodb.scala.bson.conversions.Bson +import org.mongodb.scala.{ BaseSpec, MongoNamespace } + +class BulkModelSpec extends BaseSpec { + + val namespace = new MongoNamespace("db.coll") + val filter: Bson = Document("a" -> 1) + val update: Bson = Document("$set" -> Document("b" -> 2)) + val replacement = Document("b" -> 2) + val document = Document("a" -> 1) + val updatePipeline: Seq[Document] = Seq(Document("$set" -> Document("b" -> 2))) + + it should "be able to create ClientNamespacedInsertOneModel" in { + val insertOneModel = ClientNamespacedWriteModel.insertOne(namespace, document) + insertOneModel shouldBe a[ClientNamespacedInsertOneModel] + insertOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel] + } + + it should "be able to create ClientNamespacedUpdateOneModel with filter and update" in { + val updateOneModel = ClientNamespacedWriteModel.updateOne(namespace, filter, update) + updateOneModel shouldBe a[ClientNamespacedUpdateOneModel] + updateOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel] + } + + it should "be able to create ClientNamespacedUpdateOneModel with filter, update, and options" in { + val options = ClientUpdateOneOptions.clientUpdateOneOptions() + val updateOneModel = ClientNamespacedWriteModel.updateOne(namespace, filter, update, options) + updateOneModel shouldBe a[ClientNamespacedUpdateOneModel] + updateOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel] + } + + it should "be able to create ClientNamespacedUpdateOneModel with update pipeline" in { + val updateOneModel = ClientNamespacedWriteModel.updateOne(namespace, filter, updatePipeline) + updateOneModel shouldBe a[ClientNamespacedUpdateOneModel] + updateOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel] + } + + it should "be able to create ClientNamespacedUpdateOneModel with update pipeline and options" in { + val options = ClientUpdateOneOptions.clientUpdateOneOptions() + val updateOneModel = ClientNamespacedWriteModel.updateOne(namespace, filter, updatePipeline, options) + updateOneModel shouldBe a[ClientNamespacedUpdateOneModel] + updateOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel] + } + + it should "be able to create ClientNamespacedUpdateManyModel with filter and update" in { + val updateManyModel = ClientNamespacedWriteModel.updateMany(namespace, filter, update) + updateManyModel shouldBe a[ClientNamespacedUpdateManyModel] + updateManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel] + } + it should "be able to create ClientNamespacedUpdateManyModel with filter, update and options" in { + val options = ClientUpdateManyOptions.clientUpdateManyOptions() + val updateManyModel = ClientNamespacedWriteModel.updateMany(namespace, filter, update, options) + updateManyModel shouldBe a[ClientNamespacedUpdateManyModel] + updateManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel] + } + + it should "be able to create ClientNamespacedUpdateManyModel with filter, updatePipeline" in { + val updateManyModel = ClientNamespacedWriteModel.updateMany(namespace, filter, updatePipeline) + updateManyModel shouldBe a[ClientNamespacedUpdateManyModel] + updateManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel] + } + + it should "be able to create ClientNamespacedUpdateManyModel with filter, updatePipeline and options" in { + val options = ClientUpdateManyOptions.clientUpdateManyOptions() + val updateManyModel = ClientNamespacedWriteModel.updateMany(namespace, filter, updatePipeline, options) + updateManyModel shouldBe a[ClientNamespacedUpdateManyModel] + updateManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel] + } + + it should "be able to create ClientNamespacedReplaceOneModel" in { + val replaceOneModel = ClientNamespacedWriteModel.replaceOne(namespace, filter, replacement) + replaceOneModel shouldBe a[ClientNamespacedReplaceOneModel] + replaceOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel] + } + + it should "be able to create ClientNamespacedReplaceOneModel with options" in { + val options = ClientReplaceOneOptions.clientReplaceOneOptions() + val replaceOneModel = ClientNamespacedWriteModel.replaceOne(namespace, filter, replacement, options) + replaceOneModel shouldBe a[ClientNamespacedReplaceOneModel] + replaceOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel] + } + + it should "be able to create ClientNamespacedDeleteOneModel" in { + val deleteOneModel = ClientNamespacedWriteModel.deleteOne(namespace, filter) + deleteOneModel shouldBe a[ClientNamespacedDeleteOneModel] + deleteOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel] + } + + it should "be able to create ClientNamespacedDeleteOneModel with options" in { + val options = ClientDeleteOneOptions.clientDeleteOneOptions() + val deleteOneModel = ClientNamespacedWriteModel.deleteOne(namespace, filter, options) + deleteOneModel shouldBe a[ClientNamespacedDeleteOneModel] + deleteOneModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel] + } + + it should "be able to create ClientNamespacedDeleteManyModel" in { + val deleteManyModel = ClientNamespacedWriteModel.deleteMany(namespace, filter) + deleteManyModel shouldBe a[ClientNamespacedDeleteManyModel] + deleteManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel] + } + + it should "be able to create ClientNamespacedDeleteManyModel with options" in { + val options = ClientDeleteManyOptions.clientDeleteManyOptions() + val deleteManyModel = ClientNamespacedWriteModel.deleteMany(namespace, filter, options) + deleteManyModel shouldBe a[ClientNamespacedDeleteManyModel] + deleteManyModel shouldBe a[com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel] + } +} From 94475194de213f5fcc58bd2576e47fcf3876e480 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Mon, 13 Jan 2025 12:13:22 -0800 Subject: [PATCH 2/5] Remove TODOs and change Javadoc. JAVA-5531 --- .../org/mongodb/scala/MongoCluster.scala | 32 ++++++++++--------- .../mongodb/scala/model/bulk/package.scala | 16 +++++----- .../scala/org/mongodb/scala/package.scala | 5 +++ .../scala/ApiAliasAndCompanionSpec.scala | 4 +-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala index 01a0a56f56a..a316213cc69 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala @@ -19,13 +19,11 @@ package org.mongodb.scala import com.mongodb.annotations.{ Alpha, Reason } import com.mongodb.{ ReadConcern, ReadPreference, WriteConcern } import com.mongodb.reactivestreams.client.{ MongoCluster => JMongoCluster } -import com.mongodb.ClientBulkWriteException import org.bson.codecs.configuration.CodecRegistry import org.mongodb.scala.bson.DefaultHelper.DefaultsTo import org.mongodb.scala.bson.conversions.Bson import org.mongodb.scala.model.bulk.ClientNamespacedUpdateManyModel import org.mongodb.scala.model.bulk.ClientNamespacedDeleteManyModel -import org.mongodb.scala.model.bulk.ClientNamespacedWriteModel import org.mongodb.scala.model.bulk.{ ClientBulkWriteOptions, ClientBulkWriteResult, ClientNamespacedWriteModel } import scala.collection.JavaConverters._ @@ -312,10 +310,11 @@ class MongoCluster(private val wrapped: JMongoCluster) { * @param models The [[ClientNamespacedWriteModel]] individual write operations. * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, * or the following errors: - * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * - [[ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, * and there is at least one of the following pieces of information to report: - * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], - * [[ClientBulkWriteException.getPartialResult]]. + * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. * @since 5.3 * @note Requires MongoDB 8.0 or greater. @@ -339,10 +338,11 @@ class MongoCluster(private val wrapped: JMongoCluster) { * @param options The options. * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, * or the following errors: - * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * - [[ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, * and there is at least one of the following pieces of information to report: - * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], - * [[ClientBulkWriteException.getPartialResult]]. + * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. * @since 5.3 * @note Requires MongoDB 8.0 or greater. @@ -366,14 +366,15 @@ class MongoCluster(private val wrapped: JMongoCluster) { * This operation is not supported by MongoDB Atlas Serverless instances. * * [[https://www.mongodb.com/docs/manual/reference/command/bulkWrite/ bulkWrite]] - * @param clientSession The {@linkplain ClientSession client session} with which to associate this operation. + * @param clientSession [[ClientSession client session]] with which to associate this operation. * @param models The [[ClientNamespacedWriteModel]] individual write operations. * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, * or the following errors: - * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * - [[ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, * and there is at least one of the following pieces of information to report: - * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], - * [[ClientBulkWriteException.getPartialResult]]. + * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. * @since 5.3 * @note Requires MongoDB 8.0 or greater. @@ -398,10 +399,11 @@ class MongoCluster(private val wrapped: JMongoCluster) { * @param options The options. * @return The [[SingleObservable]] signalling at most one element [[ClientBulkWriteResult]] if the operation is successful, * or the following errors: - * - [[com.mongodb.ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, + * - [[ClientBulkWriteException]]: If and only if the operation is unsuccessful or partially unsuccessful, * and there is at least one of the following pieces of information to report: - * [[ClientBulkWriteException.getWriteConcernErrors]], [[ClientBulkWriteException.getWriteErrors]], - * [[ClientBulkWriteException.getPartialResult]]. + * [[ClientBulkWriteException ClientBulkWriteException#getWriteConcernErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], + * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. * @since 5.3 * @note Requires MongoDB 8.0 or greater. diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala index fcc99533f98..a5a232878f7 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala @@ -12,14 +12,6 @@ import scala.collection.JavaConverters._ */ package object bulk { - /** - * A combination of an individual write operation and a [[MongoNamespace]] - * the operation is targeted at. - * - * @since 5.3 - */ - type ClientNamespacedWriteModel = com.mongodb.client.model.bulk.ClientNamespacedWriteModel - /** * A model for inserting a document. * @@ -62,6 +54,14 @@ package object bulk { */ type ClientNamespacedDeleteManyModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel + /** + * A combination of an individual write operation and a [[MongoNamespace]] + * the operation is targeted at. + * + * @since 5.3 + */ + type ClientNamespacedWriteModel = com.mongodb.client.model.bulk.ClientNamespacedWriteModel + object ClientNamespacedWriteModel { def insertOne[TDocument](namespace: MongoNamespace, document: TDocument): ClientNamespacedInsertOneModel = diff --git a/driver-scala/src/main/scala/org/mongodb/scala/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/package.scala index 7da5578ff96..2bd457039db 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/package.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/package.scala @@ -234,6 +234,11 @@ package object scala extends ClientSessionImplicits with ObservableImplicits wit */ type MongoBulkWriteException = com.mongodb.MongoBulkWriteException + /** + * The result of an unsuccessful or partially unsuccessful client-level bulk write operation. + */ + type ClientBulkWriteException = com.mongodb.ClientBulkWriteException + /** * An exception indicating that a failure occurred when running a `\$changeStream`. * @since 2.2 diff --git a/driver-scala/src/test/scala/org/mongodb/scala/ApiAliasAndCompanionSpec.scala b/driver-scala/src/test/scala/org/mongodb/scala/ApiAliasAndCompanionSpec.scala index 5b8e46c598d..2e21d30526a 100644 --- a/driver-scala/src/test/scala/org/mongodb/scala/ApiAliasAndCompanionSpec.scala +++ b/driver-scala/src/test/scala/org/mongodb/scala/ApiAliasAndCompanionSpec.scala @@ -153,9 +153,7 @@ class ApiAliasAndCompanionSpec extends BaseSpec { .asScala .map(_.getSimpleName) .toSet + - "MongoException" - "MongoGridFSException" - "MongoConfigurationException" - "MongoWriteConcernWithResponseException" - - // TODO-JAVA-5531 remove the `"ClientBulkWriteException"` exclusion - "ClientBulkWriteException" + "MongoException" - "MongoGridFSException" - "MongoConfigurationException" - "MongoWriteConcernWithResponseException" val objects = new Reflections( new ConfigurationBuilder() From f5b05dd70de53a0aaeaa4ee94770a23245c7d01e Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Mon, 13 Jan 2025 12:24:29 -0800 Subject: [PATCH 3/5] Increment version in since. JAVA-5531 --- .../org/mongodb/scala/MongoCluster.scala | 8 +++--- .../mongodb/scala/model/bulk/package.scala | 28 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala index a316213cc69..94c75bda724 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/MongoCluster.scala @@ -316,7 +316,7 @@ class MongoCluster(private val wrapped: JMongoCluster) { * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. - * @since 5.3 + * @since 5.4 * @note Requires MongoDB 8.0 or greater. */ def bulkWrite(models: List[_ <: ClientNamespacedWriteModel]): SingleObservable[ClientBulkWriteResult] = @@ -344,7 +344,7 @@ class MongoCluster(private val wrapped: JMongoCluster) { * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. - * @since 5.3 + * @since 5.4 * @note Requires MongoDB 8.0 or greater. */ def bulkWrite( @@ -376,7 +376,7 @@ class MongoCluster(private val wrapped: JMongoCluster) { * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. - * @since 5.3 + * @since 5.4 * @note Requires MongoDB 8.0 or greater. */ def bulkWrite( @@ -405,7 +405,7 @@ class MongoCluster(private val wrapped: JMongoCluster) { * [[ClientBulkWriteException ClientBulkWriteException#getWriteErrors]], * [[ClientBulkWriteException ClientBulkWriteException#getPartialResult]]. * - [[MongoException]]: Only if the operation is unsuccessful. - * @since 5.3 + * @since 5.4 * @note Requires MongoDB 8.0 or greater. */ def bulkWrite( diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala index a5a232878f7..e7bd9e38d27 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala @@ -8,49 +8,49 @@ import scala.collection.JavaConverters._ /** * Models, options, results for the client-level bulk write operation. * - * @since 5.3 + * @since 5.4 */ package object bulk { /** * A model for inserting a document. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedInsertOneModel = com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel /** * A model for updating at most one document matching a filter. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedUpdateOneModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel /** * A model for updating all documents matching a filter. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedUpdateManyModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel /** * A model for replacing at most one document matching a filter. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedReplaceOneModel = com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel /** * A model for deleting at most one document matching a filter. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedDeleteOneModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel /** * A model for deleting all documents matching a filter. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedDeleteManyModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel @@ -58,7 +58,7 @@ package object bulk { * A combination of an individual write operation and a [[MongoNamespace]] * the operation is targeted at. * - * @since 5.3 + * @since 5.4 */ type ClientNamespacedWriteModel = com.mongodb.client.model.bulk.ClientNamespacedWriteModel @@ -168,7 +168,7 @@ package object bulk { /** * The options to apply when executing a client-level bulk write operation. * - * @since 5.3 + * @since 5.4 */ type ClientBulkWriteOptions = com.mongodb.client.model.bulk.ClientBulkWriteOptions @@ -180,7 +180,7 @@ package object bulk { /** * The options to apply when updating a document. * - * @since 5.3 + * @since 5.4 */ type ClientUpdateOneOptions = com.mongodb.client.model.bulk.ClientUpdateOneOptions @@ -192,7 +192,7 @@ package object bulk { /** * The options to apply when updating documents. * - * @since 5.3 + * @since 5.4 */ type ClientUpdateManyOptions = com.mongodb.client.model.bulk.ClientUpdateManyOptions @@ -204,7 +204,7 @@ package object bulk { /** * The options to apply when replacing a document. * - * @since 5.3 + * @since 5.4 */ type ClientReplaceOneOptions = com.mongodb.client.model.bulk.ClientReplaceOneOptions @@ -216,7 +216,7 @@ package object bulk { /** * The options to apply when deleting a document. * - * @since 5.3 + * @since 5.4 */ type ClientDeleteOneOptions = com.mongodb.client.model.bulk.ClientDeleteOneOptions @@ -228,7 +228,7 @@ package object bulk { /** * The options to apply when deleting documents. * - * @since 5.3 + * @since 5.4 */ type ClientDeleteManyOptions = com.mongodb.client.model.bulk.ClientDeleteManyOptions From d3a6eb7e6bdf44130dd018be1e9abcce4f01bb75 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Tue, 14 Jan 2025 11:05:33 -0800 Subject: [PATCH 4/5] Remove TODOs. JAVA-5531 --- .../src/test/scala/org/mongodb/scala/MongoClientSpec.scala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala b/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala index 4f524ab79cb..781007b24ad 100644 --- a/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala +++ b/driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala @@ -37,12 +37,7 @@ class MongoClientSpec extends BaseSpec with MockitoSugar { wrapped.foreach((name: String) => { val cleanedName = name.stripPrefix("get") - - if (!cleanedName.contains("bulkWrite")) { - // TODO-JAVA-5531 remove this whole `if` block - assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name") - } - // TODO-JAVA-5531 uncomment: assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name") + assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name") }) } From 769c5368e8936d06faec1c0e796967de7f352f79 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Sun, 19 Jan 2025 18:00:56 -0800 Subject: [PATCH 5/5] Adjust javadoc and add copyright. JAVA-5531 --- .../mongodb/scala/model/bulk/package.scala | 43 ++++++++----------- .../scala/org/mongodb/scala/package.scala | 2 + 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala index e7bd9e38d27..44dcd7e3c84 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/bulk/package.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2008-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.mongodb.scala.model import org.mongodb.scala.MongoNamespace @@ -14,51 +30,37 @@ package object bulk { /** * A model for inserting a document. - * - * @since 5.4 */ type ClientNamespacedInsertOneModel = com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel /** * A model for updating at most one document matching a filter. - * - * @since 5.4 */ type ClientNamespacedUpdateOneModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel /** * A model for updating all documents matching a filter. - * - * @since 5.4 */ type ClientNamespacedUpdateManyModel = com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel /** * A model for replacing at most one document matching a filter. - * - * @since 5.4 */ type ClientNamespacedReplaceOneModel = com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel /** * A model for deleting at most one document matching a filter. - * - * @since 5.4 */ type ClientNamespacedDeleteOneModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel /** * A model for deleting all documents matching a filter. - * - * @since 5.4 */ type ClientNamespacedDeleteManyModel = com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel /** * A combination of an individual write operation and a [[MongoNamespace]] * the operation is targeted at. - * - * @since 5.4 */ type ClientNamespacedWriteModel = com.mongodb.client.model.bulk.ClientNamespacedWriteModel @@ -167,8 +169,6 @@ package object bulk { /** * The options to apply when executing a client-level bulk write operation. - * - * @since 5.4 */ type ClientBulkWriteOptions = com.mongodb.client.model.bulk.ClientBulkWriteOptions @@ -179,8 +179,6 @@ package object bulk { /** * The options to apply when updating a document. - * - * @since 5.4 */ type ClientUpdateOneOptions = com.mongodb.client.model.bulk.ClientUpdateOneOptions @@ -191,8 +189,6 @@ package object bulk { /** * The options to apply when updating documents. - * - * @since 5.4 */ type ClientUpdateManyOptions = com.mongodb.client.model.bulk.ClientUpdateManyOptions @@ -203,8 +199,6 @@ package object bulk { /** * The options to apply when replacing a document. - * - * @since 5.4 */ type ClientReplaceOneOptions = com.mongodb.client.model.bulk.ClientReplaceOneOptions @@ -215,8 +209,6 @@ package object bulk { /** * The options to apply when deleting a document. - * - * @since 5.4 */ type ClientDeleteOneOptions = com.mongodb.client.model.bulk.ClientDeleteOneOptions @@ -227,8 +219,6 @@ package object bulk { /** * The options to apply when deleting documents. - * - * @since 5.4 */ type ClientDeleteManyOptions = com.mongodb.client.model.bulk.ClientDeleteManyOptions @@ -239,6 +229,7 @@ package object bulk { /** * The result of a successful or partially successful client-level bulk write operation. + * */ type ClientBulkWriteResult = com.mongodb.client.model.bulk.ClientBulkWriteResult } diff --git a/driver-scala/src/main/scala/org/mongodb/scala/package.scala b/driver-scala/src/main/scala/org/mongodb/scala/package.scala index 2bd457039db..9a4cba0e35c 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/package.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/package.scala @@ -236,6 +236,8 @@ package object scala extends ClientSessionImplicits with ObservableImplicits wit /** * The result of an unsuccessful or partially unsuccessful client-level bulk write operation. + * + * @since 5.4 */ type ClientBulkWriteException = com.mongodb.ClientBulkWriteException