Hi i am trying to implement this exact command below using the Mongo Java api
db.system.profile.find({},{millis:1}).sort({$natural:-1}).limit(1);
I was thinking of doing something like below, but i am only expecting a single INT to be returned and this may be a wrong/long way of doing it.
Mongo mongoClient = new Mongo( "localhost" , 27017 );
DB db = mongoClient.getDB( "user" );
/* db.system.profile.find({},{millis:1}).sort({$natural:-1}).limit(1);*/
DBCollection collTime = db.getCollection("system.profile");
DBCursor cursor = collTime.find(new BasicDBObject("millis", 1),new BasicDBObject("$natural", -1)).limit(1);
System.out.println(cursor.toString());
Any help would be great!