Hello All,
I am a newbie to the MongoDB. There was a suggestion to use the MongoDB Async Java Driver API instead of Spring-Data/Mongo DB Driver API since the async API supports the callbacks and non-blocking calls to the DB. While I was going through the below links I have noticed few differences.
Async Driver API: http://mongodb.github.io/mongo-java-driver/3.0/driver-async/reference/crud/Sync Driver API: http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/crud/
The main difference of my concern is, how can we get the resultset documents into an arraylist/linkedlist using the async driver api. The async api page gives the below code block to traverse through the results, but not assigning them into a list of our choice:
// find documents
collection.find().into(new ArrayList<Document>(),
new SingleResultCallback<List<Document>>() {
@Override
public void onResult(final List<Document> result, final Throwable t) {
System.out.println("Found Documents: #" + result.size());
}
});
This copies the documents into the new ArrayList (the first argument of into method), but there is no way to get it back.
While the sync api supports the operation like below, which copies all the result documents into an arraylist.
// find documents
List<BasicDBObject> foundDocument = collection.find().into(new ArrayList<BasicDBObject>());
Is the Async API still evolving or I am missing something? Are there any utilities available specifically for async driver api Inputs are greatly appreciated.
Best Regards, Chandra.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/28fcf2e7-7cc7-42e5-8038-71d70d7708e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.