![]() |
VOOZH | about |
find_one_and_replace() method search one document if finds then replaces with the given second parameter in MongoDb. find_one_and_replace() method is differ from find_one_and_update() with the help of filter it replace the document rather than update the existing document.
Syntax:
find_one_and_replace(filter, replacement, projection=None, sort=None, return_document=ReturnDocument.BEFORE, session=None, **kwargs)
Parameters
filter: A query for replacement of a matched document.
Sample database used in all the below examples:
👁 ImageExample 1:
Output:
Example 2:
Output: