how to retrieve the latest data from mongodb python code example Example: mongodb shell query last document db.collection.find().limit(1).sort({$natural:-1})