有没有一种方法来列出与蒙戈金集合?

我已经build立了数据库连接。 我需要列出数据库中的集合名称。 可能吗?

从mongo shell向数据库显示集合:

db.getCollectionNames() 

所以要显示在蒙古皮肤收集尝试

 var collections = db.collections(); collections.each(function(err, collection) { console.log(collection); }); 

根据这个链接Mongoskin教程

 db.collectionNames(function(err, collectionArrayResult) { //Now do something with collectionArrayResult }); 

结果是具有“name”属性的对象数组,如下所示:

 [ { name: '<dbName>.<collectionName>' }, ... ] 

小心 – 但是<dbName>.system.indexes也会被返回。