Skip to content

Commit

Permalink
Refactor getCollection and hasCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
divine committed Feb 17, 2020
1 parent 2dcfa5b commit ae88c82
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Jenssegers/Mongodb/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public function hasCollection($name)
{
$db = $this->connection->getMongoDB();

$collections = $db->listCollections([
$collections = iterator_to_array($db->listCollections([
'filter' => [
'name' => $name,
],
]);
]), false);

return $collections->count() ? true : false;
return count($collections) ? true : false;
}

/**
Expand Down Expand Up @@ -143,13 +143,13 @@ public function getCollection($name)
{
$db = $this->connection->getMongoDB();

$collections = $db->listCollections([
$collections = iterator_to_array($db->listCollections([
'filter' => [
'name' => $name,
],
]);
]), false);

return $collections->count() ? (($collections = iterator_to_array($collections) ) ? current($collections) : false) : false;
return count($collections) ? current($collections) : false;
}

/**
Expand Down

0 comments on commit ae88c82

Please sign in to comment.