get the latest record of mongodb code example
Example 1: get the latest field in mongodb collection
> db.collection.findOne().sort({'_id':-1}).limit(1)
It work perfectly !
Example 2: get the latest field in mongodb collection
db.collection.find().limit(1).sort({$natural:-1})