Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support findOneAndX #89

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vertx-mongo-client/src/main/asciidoc/dataobjects.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ Get the document id that's upserted
+++
Set whether multi is enabled
+++
|[[returningNewDocument]]`returningNewDocument`|`Boolean`|
+++
Set whether new document property is enabled. Valid only on findOneAnd* methods.
+++
|[[upsert]]`upsert`|`Boolean`|
+++
Set whether upsert is enabled
Expand Down
12 changes: 11 additions & 1 deletion vertx-mongo-client/src/main/asciidoc/groovy/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,18 @@ def query = [
]

mongoClient.findBatch("book", query, { res ->

if (res.succeeded()) {

println(groovy.json.JsonOutput.toJson(res.result()))
if (res.result() == null) {

println("End of research")

} else {

println("Found doc: ${groovy.json.JsonOutput.toJson(res.result())}")

}

} else {

Expand All @@ -457,6 +466,7 @@ mongoClient.findBatch("book", query, { res ->
}
})


----

The matching documents are returned unitary in the result handler.
Expand Down
11 changes: 10 additions & 1 deletion vertx-mongo-client/src/main/asciidoc/java/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,18 @@ This has the following fields:
JsonObject query = new JsonObject().put("author", "J. R. R. Tolkien");

mongoClient.findBatch("book", query, res -> {

if (res.succeeded()) {

System.out.println(res.result().encodePrettily());
if (res.result() == null) {

System.out.println("End of research");

} else {

System.out.println("Found doc: " + res.result().encodePrettily());

}

} else {

Expand Down
12 changes: 11 additions & 1 deletion vertx-mongo-client/src/main/asciidoc/js/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,18 @@ var query = {
};

mongoClient.findBatch("book", query, function (res, res_err) {

if (res_err == null) {

console.log(JSON.stringify(res));
if (res === null) {

console.log("End of research");

} else {

console.log("Found doc: " + JSON.stringify(res));

}

} else {

Expand All @@ -458,6 +467,7 @@ mongoClient.findBatch("book", query, function (res, res_err) {
}
});


----

The matching documents are returned unitary in the result handler.
Expand Down
12 changes: 11 additions & 1 deletion vertx-mongo-client/src/main/asciidoc/ruby/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,18 @@ query = {
}

mongoClient.find_batch("book", query) { |res_err,res|

if (res_err == nil)

puts JSON.generate(res)
if (res == nil)

puts "End of research"

else

puts "Found doc: #{JSON.generate(res)}"

end

else

Expand All @@ -461,6 +470,7 @@ mongoClient.find_batch("book", query) { |res_err,res|
end
}


----

The matching documents are returned unitary in the result handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,192 @@ public Observable<JsonObject> findOneObservable(String collection, JsonObject qu
return resultHandler;
}

/**
* Find a single matching document in the specified collection and update it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param update used to describe how the documents will be updated
* @param resultHandler will be provided with the document, if any
* @return
*/
public MongoClient findOneAndUpdate(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndUpdate(collection, query, update, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and update it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param update used to describe how the documents will be updated
* @return
*/
public Observable<JsonObject> findOneAndUpdateObservable(String collection, JsonObject query, JsonObject update) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndUpdate(collection, query, update, resultHandler.toHandler());
return resultHandler;
}

/**
* Find a single matching document in the specified collection and update it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param update used to describe how the documents will be updated
* @param findOptions options to configure the find
* @param updateOptions options to configure the update
* @param resultHandler will be provided with the document, if any
* @return
*/
public MongoClient findOneAndUpdateWithOptions(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndUpdateWithOptions(collection, query, update, findOptions, updateOptions, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and update it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param update used to describe how the documents will be updated
* @param findOptions options to configure the find
* @param updateOptions options to configure the update
* @return
*/
public Observable<JsonObject> findOneAndUpdateWithOptionsObservable(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndUpdateWithOptions(collection, query, update, findOptions, updateOptions, resultHandler.toHandler());
return resultHandler;
}

/**
* Find a single matching document in the specified collection and replace it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param replace the replacement document
* @param resultHandler will be provided with the document, if any
* @return
*/
public MongoClient findOneAndReplace(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndReplace(collection, query, replace, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and replace it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param replace the replacement document
* @return
*/
public Observable<JsonObject> findOneAndReplaceObservable(String collection, JsonObject query, JsonObject replace) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndReplace(collection, query, replace, resultHandler.toHandler());
return resultHandler;
}

/**
* Find a single matching document in the specified collection and replace it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param replace the replacement document
* @param findOptions options to configure the find
* @param updateOptions options to configure the update
* @param resultHandler will be provided with the document, if any
* @return
*/
public MongoClient findOneAndReplaceWithOptions(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndReplaceWithOptions(collection, query, replace, findOptions, updateOptions, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and replace it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param replace the replacement document
* @param findOptions options to configure the find
* @param updateOptions options to configure the update
* @return
*/
public Observable<JsonObject> findOneAndReplaceWithOptionsObservable(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndReplaceWithOptions(collection, query, replace, findOptions, updateOptions, resultHandler.toHandler());
return resultHandler;
}

/**
* Find a single matching document in the specified collection and delete it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param resultHandler will be provided with the deleted document, if any
* @return
*/
public MongoClient findOneAndDelete(String collection, JsonObject query, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndDelete(collection, query, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and delete it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @return
*/
public Observable<JsonObject> findOneAndDeleteObservable(String collection, JsonObject query) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndDelete(collection, query, resultHandler.toHandler());
return resultHandler;
}

/**
* Find a single matching document in the specified collection and delete it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param findOptions options to configure the find
* @param resultHandler will be provided with the deleted document, if any
* @return
*/
public MongoClient findOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions, Handler<AsyncResult<JsonObject>> resultHandler) {
delegate.findOneAndDeleteWithOptions(collection, query, findOptions, resultHandler);
return this;
}

/**
* Find a single matching document in the specified collection and delete it.
* <p>
* This operation might change <i>_id</i> field of <i>query</i> parameter
* @param collection the collection
* @param query the query used to match the document
* @param findOptions options to configure the find
* @return
*/
public Observable<JsonObject> findOneAndDeleteWithOptionsObservable(String collection, JsonObject query, FindOptions findOptions) {
io.vertx.rx.java.ObservableFuture<JsonObject> resultHandler = io.vertx.rx.java.RxHelper.observableFuture();
findOneAndDeleteWithOptions(collection, query, findOptions, resultHandler.toHandler());
return resultHandler;
}

/**
* Count matching documents in a collection.
* @param collection the collection
Expand Down
Loading