diff --git a/plugins/dbgate-plugin-mongo/src/backend/Analyser.js b/plugins/dbgate-plugin-mongo/src/backend/Analyser.js index a4df793f..9926c68d 100644 --- a/plugins/dbgate-plugin-mongo/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-mongo/src/backend/Analyser.js @@ -6,15 +6,24 @@ class Analyser extends DatabaseAnalyser { } async _runAnalysis() { - const collections = await this.pool.__getDatabase().listCollections().toArray(); + const collectionsAndViews = await this.pool.__getDatabase().listCollections().toArray(); + const collections = collectionsAndViews.filter((x) => x.type == 'collection'); + const views = collectionsAndViews.filter((x) => x.type == 'view'); - const stats = await Promise.all(collections.map((x) => this.pool.__getDatabase().collection(x.name).stats())); + const stats = await Promise.all( + collections.filter((x) => x.type == 'collection').map((x) => this.pool.__getDatabase().collection(x.name).stats()) + ); const res = this.mergeAnalyseResult({ - collections: collections.map((x, index) => ({ - pureName: x.name, - tableRowCount: stats[index].count, - })), + collections: [ + ...collections.map((x, index) => ({ + pureName: x.name, + tableRowCount: stats[index].count, + })), + ...views.map((x, index) => ({ + pureName: x.name, + })), + ], }); // console.log('MERGED', res); return res;