/** * Gets the number of documents matching the filter. * * @see Count::__construct() for supported options * @param array|object $filter Query by which to filter documents * @param array $options Command options * @return integer */ public function count($filter = [], array $options = []) { if (!isset($options['readConcern'])) { $options['readConcern'] = $this->readConcern; } if (!isset($options['readPreference'])) { $options['readPreference'] = $this->readPreference; } $operation = new Count($this->databaseName, $this->collectionName, $filter, $options); $server = $this->manager->selectServer($options['readPreference']); return $operation->execute($server); }
/** * Gets the number of documents matching the filter. * * @see Count::__construct() for supported options * @param array|object $filter Query by which to filter documents * @param array $options Command options * @return integer */ public function count($filter = array(), array $options = array()) { $operation = new Count($this->databaseName, $this->collectionName, $filter, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }