/** * Updates at most one document matching the filter. * * @see UpdateOne::__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 $update Update to apply to the matched document * @param array $options Command options * * @return UpdateResult */ public function updateOne($filter, $update, array $options = []) { if (!isset($options['writeConcern'])) { $options['writeConcern'] = $this->writeConcern; } $operation = new UpdateOne($this->databaseName, $this->collectionName, $filter, $update, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }