/** * Deletes all documents matching the filter. * * @see DeleteMany::__construct() for supported options * @see http://docs.mongodb.org/manual/reference/command/delete/ * * @param array|object $filter Query by which to delete documents * @param array $options Command options * * @return DeleteResult */ public function deleteMany($filter, array $options = []) { if (!isset($options['writeConcern'])) { $options['writeConcern'] = $this->writeConcern; } $operation = new DeleteMany($this->databaseName, $this->collectionName, $filter, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }