浏览代码

use db.listCollections() for API /mongo/collections

Yuki Takei 6 年之前
父节点
当前提交
81991c0469
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/server/routes/apiv3/mongo.js

+ 2 - 1
src/server/routes/apiv3/mongo.js

@@ -34,7 +34,8 @@ module.exports = (crowi) => {
    *                      type: string
    */
   router.get('/collections', async(req, res) => {
-    const collections = Object.keys(mongoose.connection.collections);
+    const listCollectionsResult = await mongoose.connection.db.listCollections().toArray();
+    const collections = listCollectionsResult.map(collectionObj => collectionObj.name);
 
     // TODO: use res.apiv3
     return res.json({