Laravel-mongodb: List all collections

Created on 15 Mar 2018  路  1Comment  路  Source: jenssegers/laravel-mongodb

Hi,
I have a requirement to list all tables through code previously is built in mysql. Now I am using this plugin to list all collections but i cant find a replacement of below here:

$tables = DB::select('SHOW TABLES');

Any help would be appreciated

question

Most helpful comment

For anyone coming from google
Here is the available way to list all collections in the database.

foreach (\DB::connection()->getMongoDB()->listCollections() as $collection) {
    echo $collection->getName() ;
}

>All comments

For anyone coming from google
Here is the available way to list all collections in the database.

foreach (\DB::connection()->getMongoDB()->listCollections() as $collection) {
    echo $collection->getName() ;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

YSimple picture YSimple  路  3Comments

BlakeGardner picture BlakeGardner  路  3Comments

geofflancaster picture geofflancaster  路  3Comments

lgt picture lgt  路  3Comments

bastiendonjon picture bastiendonjon  路  3Comments