get the latest field in mongodb collection
snippet in c

mongodb shell query last document

user7168

db.collection.find().limit(1).sort({$natural:-1})

get the latest field in mongodb collection

user2129

> db.collection.findOne().sort({'_id':-1}).limit(1)

It work perfectly !

get the latest field in mongodb collection

user2816

db.collection.find().limit(1).sort({$natural:-1})