MongoDB Java Driver Equivalent of Snapshot for MongoCursor MongoDB Java Driver Equivalent of Snapshot for MongoCursor mongodb mongodb

MongoDB Java Driver Equivalent of Snapshot for MongoCursor


After banging a few things through an checking the profiler logs I actually got a confirmation on this:

MongoCursor<Document> cursor = collection.find().modifiers(    new Document("$snapshot", true)).iterator();

So you need to call the .modifiers() while still on a FindIterable with $snapshot as true. This is consistent over the wire with the .snaphot() cursor modifier.

Both record in the profiler like this:

   "query" : {            "find" : "sample",            "filter" : {            },            "snapshot" : true    },

Showing the correct modifier placed.