Hi everybody!
I’m trying to automate an update task in python. My query works well when ran on Compass, but nothing happens in python…
I have a collection one field (companiesId) in documents containing one or more values, eg [“00999”,“002601”,“00486”]
I want to update all documents and change the “00999” value to “8000999” while keeping other values.
For my example, I’d like to have [“8000999”,“002601”,“00486”] as result.
I can acheive this with the query :
db.utilisateurs.updateMany(
{‘companiesId’ : “8000999”},
{$set: {“companiesId.$” : “00999”}}
)
In My Python script, I use:
collection = db.utilisateurs
collection.update_many({‘companiesId’: ‘00999’}, {"$set" : {“companiesId.$” : ‘8000999’} })
but nothing happens (no error message).
Any hints here?
Thanks a lot and have a nice day!