I\'ve a mongodb collection in this form:
{id=ObjectId(....),key={dictionary of values}} where dictionary of values is {\'a\':\'1\',\'b\':\'2\'.....} <
{id=ObjectId(....),key={dictionary of values}} where dictionary of values is {\'a\':\'1\',\'b\':\'2\'.....}
With my pymongo version: 3.2.2 I had do the following
from bson.objectid import ObjectId import pymongo client = pymongo.MongoClient("localhost", 27017) db = client.mydbname db.ProductData.update_one({ '_id': ObjectId(p['_id']['$oid']) },{ '$set': { 'd.a': existing + 1 } }, upsert=False)