'Java Spring and Mongo - Iterate through a cursor in a document
I'm using the mongo dependency in a Spring java application. I need to iterate through a cursor after I use runCommand.
MongoDatabase db = mongoClient.getDatabase("database");
Bson command = Document.parse("{ \"find\": \"collection\", \"filter\": { \"field\": \"value\" } }");
Document result = db.runCommand(command);
System.out.println(result)
It returns : Document{{cursor=Document{{firstBatch=[Document{{}}]}}}}
I can access the cursor with result.get("cursor") but it still returns a document. How can I achieve this please?
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
