testdb.update_one({'id': id}, {"$set": {'testArrayLevel1.$[i].testArrayLevel2.$[j].status':"registered"}},{"array_filters":[{"i.user_id":user_id}, {"j.user_type": user_type}]}, upsert=False)
Getting TypeError:
update() got multiple values for argument 'upsert'. If removed upsert=False, then getting:
TypeError: upsert must be True or False
What is the correct way to do this python code calling pymongo? Any inputs will be of great help.
The problem in the way you pass args to function, the value_args is malformed, so instead of
testdb.update_one({'id': id}, {"$set": {'testArrayLevel1.$[i].testArrayLevel2.$[j].status':"registered"}},{"array_filters":[{"i.user_id":user_id}, {"j.user_type": user_type}]}, upsert=False)
Use right passing for value_args, also formatting will make your life eathier:
testdb.update_one({'id': id},
{
"$set": {'testArrayLevel1.$[i].testArrayLevel2.$[j].status':"registered"},
"array_filters":[{"i.user_id":user_id}, {"j.user_type": user_type}]
},
upsert=False)
NOTE By default upsert is set to false, so may want to consider removing it, as I believe you used same call and the upsert were set to dict, which won't be the case after fixing arguments.
The right usage is here ( got the right comamnd after posting another question):
mongo.db.testdb.update_one({'id': id},
{"$set": {'testArrayLevel1.$[i].testArrayLevel2.$[j].status': "registered"}},
array_filters=[{"i.user_name": user_name}, {"j.user_type": user_type}],
upsert=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With