pythonmongodbmotordriver

Python Motor MongoDB client findAndModify


Standard MongoDB driver for Python PyMongo has a method find_and_modify, but async client Motor doesn't have something like this. There are some suggestions in the documentation about findAndModify command but there is no an example how to use it.

How can I use findAndModify in Motor?


Solution

  • The find_and_modify method seems to be deprecated, in client libraries at least.

    There's a find_one_and_update method in PyMongo and Motor, which serves the same purpose.

    There is more detail here: https://stackoverflow.com/a/54165097/