From 8debb80c7e024deeb65c12a7a7fe25cf7c227265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Wed, 10 Jan 2024 12:58:06 +0100 Subject: [PATCH] Add missing methods to ReactiveMongoCollection Fixes #38114 --- .../impl/ReactiveMongoCollectionImpl.java | 63 +++++++ .../reactive/ReactiveMongoCollection.java | 169 ++++++++++++++++++ 2 files changed, 232 insertions(+) diff --git a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoCollectionImpl.java b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoCollectionImpl.java index acac2af661e43..a122df0796b70 100644 --- a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoCollectionImpl.java +++ b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoCollectionImpl.java @@ -584,6 +584,27 @@ public Uni updateOne(ClientSession clientSession, Bson filter, Bso return Wrappers.toUni(collection.updateOne(clientSession, filter, update, options)); } + @Override + public Uni updateOne(Bson filter, List update) { + return Wrappers.toUni(collection.updateOne(filter, update)); + } + + @Override + public Uni updateOne(Bson filter, List update, UpdateOptions options) { + return Wrappers.toUni(collection.updateOne(filter, update, options)); + } + + @Override + public Uni updateOne(ClientSession clientSession, Bson filter, List update) { + return Wrappers.toUni(collection.updateOne(clientSession, filter, update)); + } + + @Override + public Uni updateOne(ClientSession clientSession, Bson filter, List update, + UpdateOptions options) { + return Wrappers.toUni(collection.updateOne(clientSession, filter, update, options)); + } + @Override public Uni updateMany(Bson filter, Bson update) { return Wrappers.toUni(collection.updateMany(filter, update)); @@ -605,6 +626,27 @@ public Uni updateMany(ClientSession clientSession, Bson filter, Bs return Wrappers.toUni(collection.updateMany(clientSession, filter, update, options)); } + @Override + public Uni updateMany(Bson filter, List update) { + return Wrappers.toUni(collection.updateMany(filter, update)); + } + + @Override + public Uni updateMany(Bson filter, List update, UpdateOptions options) { + return Wrappers.toUni(collection.updateMany(filter, update, options)); + } + + @Override + public Uni updateMany(ClientSession clientSession, Bson filter, List update) { + return Wrappers.toUni(collection.updateMany(clientSession, filter, update)); + } + + @Override + public Uni updateMany(ClientSession clientSession, Bson filter, List update, + UpdateOptions options) { + return Wrappers.toUni(collection.updateMany(clientSession, filter, update, options)); + } + @Override public Uni findOneAndDelete(Bson filter) { return Wrappers.toUni(collection.findOneAndDelete(filter)); @@ -667,6 +709,27 @@ public Uni findOneAndUpdate(ClientSession clientSession, Bson filter, Bson up return Wrappers.toUni(collection.findOneAndUpdate(clientSession, filter, update, options)); } + @Override + public Uni findOneAndUpdate(Bson filter, List update) { + return Wrappers.toUni(collection.findOneAndUpdate(filter, update)); + } + + @Override + public Uni findOneAndUpdate(Bson filter, List update, FindOneAndUpdateOptions options) { + return Wrappers.toUni(collection.findOneAndUpdate(filter, update, options)); + } + + @Override + public Uni findOneAndUpdate(ClientSession clientSession, Bson filter, List update) { + return Wrappers.toUni(collection.findOneAndUpdate(clientSession, filter, update)); + } + + @Override + public Uni findOneAndUpdate(ClientSession clientSession, Bson filter, List update, + FindOneAndUpdateOptions options) { + return Wrappers.toUni(collection.findOneAndUpdate(clientSession, filter, update, options)); + } + @Override public Uni drop() { return Wrappers.toUni(collection.drop()); diff --git a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/reactive/ReactiveMongoCollection.java b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/reactive/ReactiveMongoCollection.java index 65ecdb58f72a4..34c7532d1a7c8 100644 --- a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/reactive/ReactiveMongoCollection.java +++ b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/reactive/ReactiveMongoCollection.java @@ -1014,6 +1014,62 @@ Uni replaceOne(ClientSession clientSession, Bson filter, T replace Uni updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options); + /** + * Update a single document in the collection according to the specified arguments. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the UpdateResult + */ + Uni updateOne(Bson filter, List update); + + /** + * Update a single document in the collection according to the specified arguments. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the update operation + * @return a publisher with a single element the UpdateResult + */ + Uni updateOne(Bson filter, List update, UpdateOptions options); + + /** + * Update a single document in the collection according to the specified arguments. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the UpdateResult + */ + Uni updateOne(ClientSession clientSession, Bson filter, List update); + + /** + * Update a single document in the collection according to the specified arguments. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the update operation + * @return a publisher with a single element the UpdateResult + */ + Uni updateOne(ClientSession clientSession, Bson filter, List update, UpdateOptions options); + /** * Update all documents in the collection according to the specified arguments. * @@ -1059,6 +1115,46 @@ Uni updateOne(ClientSession clientSession, Bson filter, Bson updat Uni updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options); + /** + * Update all documents in the collection according to the specified arguments. + * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the UpdateResult + */ + Uni updateMany(Bson filter, List update); + + /** + * Update all documents in the collection according to the specified arguments. + * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the update operation + * @return a publisher with a single element the UpdateResult + */ + Uni updateMany(Bson filter, List update, UpdateOptions options); + + /** + * Update all documents in the collection according to the specified arguments. + * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the UpdateResult + */ + Uni updateMany(ClientSession clientSession, Bson filter, List update); + + /** + * Update all documents in the collection according to the specified arguments. + * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the update operation + * @return a publisher with a single element the UpdateResult + */ + Uni updateMany(ClientSession clientSession, Bson filter, List update, UpdateOptions options); + /** * Atomically find a document and remove it. * @@ -1217,6 +1313,79 @@ Uni findOneAndReplace(ClientSession clientSession, Bson filter, T replacement Uni findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options); + /** + * Atomically find a document and update it. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the document that was updated. Depending on the value of the + * {@code returnOriginal} + * property, this will either be the document as it was before the update or as it is after the update. If no + * documents matched the + * query filter, then null will be returned + */ + Uni findOneAndUpdate(Bson filter, List update); + + /** + * Atomically find a document and update it. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the operation + * @return a publisher with a single element the document that was updated. Depending on the value of the + * {@code returnOriginal} + * property, this will either be the document as it was before the update or as it is after the update. If no + * documents matched the + * query filter, then null will be returned + */ + Uni findOneAndUpdate(Bson filter, List update, FindOneAndUpdateOptions options); + + /** + * Atomically find a document and update it. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @return a publisher with a single element the document that was updated. Depending on the value of the + * {@code returnOriginal} + * property, this will either be the document as it was before the update or as it is after the update. If no + * documents matched the + * query filter, then null will be returned + */ + Uni findOneAndUpdate(ClientSession clientSession, Bson filter, List update); + + /** + * Atomically find a document and update it. + * + *

+ * Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. + *

+ * + * @param clientSession the client session with which to associate this operation + * @param filter a document describing the query filter, which may not be null. + * @param update a pipeline describing the update, which may not be null. + * @param options the options to apply to the operation + * @return a publisher with a single element the document that was updated. Depending on the value of the + * {@code returnOriginal} + * property, this will either be the document as it was before the update or as it is after the update. If no + * documents matched the + * query filter, then null will be returned + */ + Uni findOneAndUpdate(ClientSession clientSession, Bson filter, List update, + FindOneAndUpdateOptions options); + /** * Drops this collection from the database. *