I am trying to retrieve one element from a mongo collection, the one with the greatest _id field. I know this can be done by querying:
db.collection.find().s
import pymongo tonystark = pymongo.MongoClient("mongodb://localhost:27017/") mydb = tonystark["tonystark_db"] savings = mydb["customers"] x = savings.find().sort("_id") for s in x: print(s)