Commit ae88c82d authored by Ditty's avatar Ditty

Refactor getCollection and hasCollection

parent 2dcfa5b5
...@@ -40,13 +40,13 @@ class Builder extends \Illuminate\Database\Schema\Builder ...@@ -40,13 +40,13 @@ class Builder extends \Illuminate\Database\Schema\Builder
{ {
$db = $this->connection->getMongoDB(); $db = $this->connection->getMongoDB();
$collections = $db->listCollections([ $collections = iterator_to_array($db->listCollections([
'filter' => [ 'filter' => [
'name' => $name, 'name' => $name,
], ],
]); ]), false);
return $collections->count() ? true : false; return count($collections) ? true : false;
} }
/** /**
...@@ -143,13 +143,13 @@ class Builder extends \Illuminate\Database\Schema\Builder ...@@ -143,13 +143,13 @@ class Builder extends \Illuminate\Database\Schema\Builder
{ {
$db = $this->connection->getMongoDB(); $db = $this->connection->getMongoDB();
$collections = $db->listCollections([ $collections = iterator_to_array($db->listCollections([
'filter' => [ 'filter' => [
'name' => $name, 'name' => $name,
], ],
]); ]), false);
return $collections->count() ? (($collections = iterator_to_array($collections) ) ? current($collections) : false) : false; return count($collections) ? current($collections) : false;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment