یکی را پیدا کن(Find One)


برای انتخاب داده‌ها از مجموعه‌ای در MongoDB، می‌توانیم از
روش find_one().


متد find_one() اولین مورد را برمی‌گرداند
رخ دادن در انتخاب.



مثال


Find the first document in the customers collection:



import pymongo

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

mydb = myclient["mydatabase"]
mycol = mydb["customers"]


x = mycol.find_one()

print(x)