I’m trying to remove the keys from a mongoengine Document in python:
document.update(unset__name=True)
document.update(unset__surname=True)
document.update(unset__dob=True)
...
but instead of the above I would like to loop through them and use a variable, something like:
document.update(unset__<key>=True)
Is this possible?
2
Answers
with a map ? you can build it and put as function kwargs
yes, this is feasible by destructuring a dictionary.
For example, like in there:
In your case, you will simply have to build a dictionnary with all the keys you want to destroy, by building the correct string: