Hello! I use mongodb changeStream with watch method and my mission is to pack 100 documents from changeStream. Below is my basic sources.
mongo = MongoClient('localhost', 27017, replicaSet='replica01')
target_coll = [
'coll_earn_Construction_month', 'coll_earn_Education_and_Health_Services_mon',
'coll_earn_Financial_Activities_month', 'coll_earn_Goods_Producing_month'
]
database = 'etlmongodb'
pipeline = [{'$match': {'operationType': 'insert'}}, {'$match': {'ns.coll': {'$in' : target_coll}}}]
results = mongo[database].watch(pipeline)
from pprint import pprint
for result in results:
pprint(result)
These codes work correctly. But I have no idea how to count the returned documents number. I want to know how to recognize the number of returned documents reaches 100 with pymongo api.
Any idea will be deeply appreciated. Best regards