/** * Replaces at most one document matching the filter. * * @see ReplaceOne::__construct() for supported options * @see http://docs.mongodb.org/manual/reference/command/update/ * * @param array|object $filter Query by which to filter documents * @param array|object $replacement Replacement document * @param array $options Command options * * @return UpdateResult */ public function replaceOne($filter, $replacement, array $options = []) { if (!isset($options['writeConcern'])) { $options['writeConcern'] = $this->writeConcern; } $operation = new ReplaceOne($this->databaseName, $this->collectionName, $filter, $replacement, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }