Phalcon\Db\Adapter\MongoDB\Collection::findOneAndReplace PHP Method

findOneAndReplace() public method

The document to return may be null if no document matched the filter. By default, the original document is returned. Specify FindOneAndReplace::RETURN_DOCUMENT_AFTER for the "returnDocument" option to return the updated document. Note: BSON deserialization of the returned document does not yet support a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
See also: FindOneAndReplace::__construct() for supported options
See also: http://docs.mongodb.org/manual/reference/command/findAndModify/
public findOneAndReplace ( array | object $filter, array | object $replacement, array $options = [] ) : object | null
$filter array | object Query by which to filter documents
$replacement array | object Replacement document
$options array Command options
return object | null
    public function findOneAndReplace($filter, $replacement, array $options = [])
    {
        $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
        if (!isset($options['writeConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
            $options['writeConcern'] = $this->writeConcern;
        }
        $operation = new FindOneAndReplace($this->databaseName, $this->collectionName, $filter, $replacement, $options);
        return $operation->execute($server);
    }