I have a dictionary of data that looks for example like this:
dict = [{'name': 'test', 'domain': 'www.example.com', 'rawdata':'dbe318e7'},
{'name': 'test2', 'domain': 'www.example.com', 'rawdata':'dbe318e8'},
{'name': 'test3', 'domain': 'www.example.com', 'rawdata':'dbe318e8'}]
I want to do an upsert into mongodb using pymongo where 'rawdata' should be unique and I have it working with this:
for x in dict:
myColl.update({'rawdata': x['rawdata']}, x, True)
But is this the best way to do it or is there a simpler upsert without looping on the dictionary?