1.查询数据
find:
find(filter=None,projection=None,skip=0,limit=0,no_cursor_timeout=False,
cursor_type=CursorType.NON_TAILABLE,sort=None, allow_partial_results=False, oplog_replay=False,modifiers=None, manipulate=True)
cursor = db.restaurants.find()
for document in cursor:
print(document)
# 查询字段是最上层的
cursor = db.restaurants.find({"borough": "Manhattan"})
# 查询字段在内层嵌套中
cursor = db.restaurants.find({"address.zipcode": "10075"})
cursor = db.restaurants.find({"grades.score": {"$gt": 30}})
cursor = db.restaurants.find({"grades.score": {"$lt": 10}})
# AND
cursor = db.restaurants.find({"cuisine": "Italian", "address.zipcode": "10075"})
cursor = db.restaurants.find(
{"$or": [{"cuisine": "Italian"}, {"address.zipcode": "10075"}]})
find_one
find_one(filter_or_id=None, *args, **kwargs)