MongoCursor to MongoCollection

Right now, I am upgrading java mongodb legacy driver to mongodb driver sync. In DBCursor class, there was the method “.getCollection()”, it gets the DBCollection from the object of DBCursor, but MongoCursor class does not have such method (I want to get the MongoCollection from MongoCursor object). Is there any way to do this?

There is not. Generally the new API does not include these sort of back pointers, e.g. MongoCollection to MongoDatabase, etc. One good reason not to for MongoCursor is that cursors can operate at a higher level than a single collection for some operations, so there is no single MongoCollection to associate it with.