import pymongo
from bson.objectid import ObjectId
client = pymongo.MongoClient(host='localhost', port=27017)
db = client['book']
collection = db['biquge']
results = collection.find({"name": "雪中悍刀行"})
print(results)
for result in results:
print(result)
count = collection.count_documents({"name": "雪中悍刀行"})
print(count)
r = collection.find().sort('name', pymongo.ASCENDING)
print([i for i in r])
rc = collection.find({"name": "雪中悍刀行"}).limit(1)
print([i for i in rc])
rc1 = collection.find({"name": "雪中悍刀行"}).skip(2)
print([i for i in rc1])
rc2 = collection.find({'_id': {'$gt': ObjectId("61c1469582efaeb690729ebc")}})
print([i for i in rc2])