Skip to content

Commit c7899d9

Browse files
committed
Use listCollectionNames
1 parent 3ae0b99 commit c7899d9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Schema/Builder.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ public function getTables()
114114
$db = $this->connection->getMongoDB();
115115
$collections = [];
116116

117-
foreach ($db->listCollections() as $collectionInfos) {
118-
$stats = $db->selectCollection($collectionInfos->getName())->aggregate([
117+
foreach ($db->listCollectioNames() as $collectionName) {
118+
$stats = $db->selectCollection($collectionName)->aggregate([
119119
['$collStats' => ['storageStats' => ['scale' => 1]]],
120120
['$project' => ['storageStats.totalSize' => 1]],
121121
])->toArray();
122122

123123
$collections[] = [
124-
'name' => $collectionInfos->getName(),
124+
'name' => $collectionName,
125125
'schema' => null,
126126
'size' => $stats[0]?->storageStats?->totalSize ?? null,
127127
'comment' => null,
@@ -139,12 +139,7 @@ public function getTables()
139139

140140
public function getTableListing()
141141
{
142-
$db = $this->connection->getMongoDB();
143-
$collections = [];
144-
145-
foreach ($db->listCollections() as $collectionInfos) {
146-
$collections[] = $collectionInfos->getName();
147-
}
142+
$collections = iterator_to_array($this->connection->getMongoDB()->listCollectionNames());
148143

149144
sort($collections);
150145

0 commit comments

Comments
 (0)