Я хотел бы проверить количество документов, вставленных в мою коллекцию.Обновление коллекции в pymongo
Вот мой код в Python:
from pymongo import MongoClient
connection = MongoClient()
db = connection['mydatabase']
collection1 = db.mycollection
collection2=db.mycollection1
pipe = [{......}]
result = collection1.aggregate(pipe, allowDiskUse=True)
array = list(result)
length = len(array)
for res in result:
id = res['_id']
collection2.update({..}, upsert=True)
count = collection2.find().count()
print ("There are %d documents in users collection" %count)
if length == count:
print("insertion ok")
else:
print("echec")
connection.close()
проблема, что после того, как для постановки, мой результат пуст, и поэтому Len равна нулю. Я не знаю, что случилось. Спасибо