| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- const loggerFactory = require('@alias/logger');
- const logger = loggerFactory('growi:routes:apiv3:mongo'); // eslint-disable-line no-unused-vars
- const express = require('express');
- const router = express.Router();
- /**
- * @swagger
- * tags:
- * name: Mongo
- */
- module.exports = (crowi) => {
- /**
- * @swagger
- *
- * /mongo/collections:
- * get:
- * tags: [Mongo]
- * description: get mongodb collections names
- * responses:
- * 200:
- * description: a list of collections in mongoDB
- * content:
- * application/json:
- * schema:
- * properties:
- * collections:
- * type: array
- * items:
- * type: string
- */
- router.get('/collections', async(req, res) => {
- const collections = Object.values(crowi.models).map(model => model.collection.collectionName);
- // TODO: use res.apiv3
- return res.json({
- ok: true,
- collections: [...new Set(collections)], // remove duplicates
- });
- });
- return router;
- };
|