mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed reading DB with mongo views #476
This commit is contained in:
parent
dc6eff7f9e
commit
8fe6cb1f71
@ -6,15 +6,24 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _runAnalysis() {
|
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({
|
const res = this.mergeAnalyseResult({
|
||||||
collections: collections.map((x, index) => ({
|
collections: [
|
||||||
pureName: x.name,
|
...collections.map((x, index) => ({
|
||||||
tableRowCount: stats[index].count,
|
pureName: x.name,
|
||||||
})),
|
tableRowCount: stats[index].count,
|
||||||
|
})),
|
||||||
|
...views.map((x, index) => ({
|
||||||
|
pureName: x.name,
|
||||||
|
})),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
// console.log('MERGED', res);
|
// console.log('MERGED', res);
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user