I am very confused about java drivers for Mongodb. Reading the official documentation, it seems that you can use the regular MondoDB driver or the Async MongoDB driver.
First question: Can I use both in one application or do I need to choose one?
Trying to use the Async driver, I found things that I used (with a regular driver) in which I got a little lost. For example, I used this:
FindIterable<Document> iterable = db.getCollection("my_coll").find(query);
String json = JSON.serialize(iterable);
And now I really don't know how to convert the result to a json string, since they did not include the class JSON
from the Async driver. Second question: If I cannot use both drivers at the same time, how can I serialize FindIterable<Document>
?
source
share