MongoDB: Search for documents without a property and add it with pymongo.
from pymongo import MongoClient client = MongoClient("myconnectionstring") db = client.mydb cursor = db.mydocs.find({"myproperty": None}) for document in cursor: print(document["_id"]) db.mydocs.update({"_id": document["_id"]}, {"$set": {"myproperty": "myvalue"}})