public function query($collectionName, $options = [])
{
$databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName;
$token = $this->log('find', array_merge(['ns' => $databaseName . '.' . $collectionName, 'filter' => $this->document], $options), __METHOD__);
$readConcern = $this->getReadConcern();
if ($readConcern !== null) {
$options['readConcern'] = $readConcern;
}
try {
$this->beginProfile($token, __METHOD__);
$query = new \MongoDB\Driver\Query($this->document, $options);
$this->db->open();
$server = $this->db->manager->selectServer($this->getReadPreference());
$cursor = $server->executeQuery($databaseName . '.' . $collectionName, $query);
$cursor->setTypeMap($this->db->typeMap);
$this->endProfile($token, __METHOD__);
} catch (RuntimeException $e) {
$this->endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), $e->getCode(), $e);
}
return $cursor;
}