python - Iterating over a mongodb collection doesn't return all objects -
i have cron job runs simple script on mongo database:
import pymongo db=pymongo.connection().dbase ids=[] obj in db.coll.find(): ids.append(obj['_id']) # log len(ids), db.coll.count()
in logs db.coll.count() 651 , len(ids) 651 too, 5,85,71 or other random numbers below 651. can explain why discrepancy happens , how prevent please?
the environment is: standalone server multiple clients may update objects in collection concurrently.
Comments
Post a Comment