mongo query to get last 5 entered records pymongo code example Example: mongodb shell query last document db.collection.find().limit(1).sort({$natural:-1})