Update all documents in a collection using PyMongo
Let's say you need to add a field to every document in a collection.
The find method returns a Cursor, on which you can easily iterate over using the for in syntax. Then, we call theupdate method, specifying the _id and that we add a field ($set). The parameters upsert and multi come from mongodb (see here for more info).