Details
Description
Iterating through a resultset and adding news fields to the objects results in a corrupted iterator.
A simple test like the following code iterates many times over the same objects ... am I missing something? (see the attached file for a complete example)
-
- sample code ##
total_obj = db.test.find().count()
count = 0
for item in db.test.find():
db.test.update( {'_id':_id}, {'$set' : {'some_new_data' : random.randint(0, 1000)}})
count = count +1
- sample code ##
print count,total_obj
-
- /sample code ##
script usage:
python mongo_find_and_update.py test_db