I have a requirement where I want to update 1000 records in the Couchbase and get the ids of the updated record back. I don’t want to use Reactive (project reactor) as mentioned in the official document of couchbase SDK 3.x.
there is one more approach where we can use the CompletableFuture on the service side and call the AsynCluster.query(queryStatment) which also return CompletableFuture back.
is there any way to perform 1000 update(to be precise update with select "UPDATE bucketName SET docType = ‘abc’ “WHERE caseId = 123 RETURNING caseId as caseId ;”) operation and return caseID back and do this task asynchronously.
i tried with below code but not sure about it.
List <CompletableFuture<QueryResult>> completableFutureList = new ArrayList<>();
for(JsonObject j : jsonObjectList) {
completableFutureList.add(asyncCluster.query(queryStatement,
QueryOptions.queryOptions().parameters(j)));}
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]))
.exceptionally(ex-> null).join();
it should work asynchronously and return the list of caseIds that are successfully updated and also handle any exception that occurred while doing the update operation and catch that separately.