From b0d78250e1bbce775af20cef8583c36fba138317 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 22 Dec 2022 17:35:46 +0100 Subject: [PATCH] row count info added to mongoDB --- plugins/dbgate-plugin-mongo/src/backend/Analyser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/dbgate-plugin-mongo/src/backend/Analyser.js b/plugins/dbgate-plugin-mongo/src/backend/Analyser.js index 93265986..a4df793f 100644 --- a/plugins/dbgate-plugin-mongo/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-mongo/src/backend/Analyser.js @@ -8,9 +8,12 @@ class Analyser extends DatabaseAnalyser { async _runAnalysis() { const collections = await this.pool.__getDatabase().listCollections().toArray(); + const stats = await Promise.all(collections.map((x) => this.pool.__getDatabase().collection(x.name).stats())); + const res = this.mergeAnalyseResult({ - collections: collections.map((x) => ({ + collections: collections.map((x, index) => ({ pureName: x.name, + tableRowCount: stats[index].count, })), }); // console.log('MERGED', res);