Folks:
I have a MongoDB database application with a Python Flask front end using pymongo. I am having difficulty updating only the embedded document within a collection. I have no issues updating the entire collection from an HTML form.
For example, I have no issues with:
db.polymers.update_one({ “_id”: polymer_id}, {"$set": {“name”: name, “composition”: {“monomer01”: monomer01, “monomer02”: monomer02, “mw”: 10000 }, … “comments”: comments}})
However, trying to update only one element within the embedded document named “composition” doesn’t update as expected. And there isn’t even an error message. Here is the statement:
db.polymers.update_one({"_id": polymer_id},{"$set": {“composition”: {“mw”: 15000}}})
I would appreciate any help! Thanks!
Mike.