mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
show mongo collection sizes #552
This commit is contained in:
@@ -16,12 +16,16 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
collections
|
collections
|
||||||
.filter((x) => x.type == 'collection')
|
.filter((x) => x.type == 'collection')
|
||||||
.map((x) =>
|
.map((x) =>
|
||||||
this.dbhan
|
this.dbhan
|
||||||
.getDatabase()
|
.getDatabase()
|
||||||
.collection(x.name)
|
.collection(x.name)
|
||||||
.aggregate([{ $collStats: { count: {} } }])
|
.aggregate([{ $collStats: { count: {}, storageStats: {} } }])
|
||||||
.toArray()
|
.toArray()
|
||||||
.then((resp) => ({ name: x.name, count: resp[0].count }))
|
.then((resp) => ({
|
||||||
|
name: x.name,
|
||||||
|
count: resp[0].count,
|
||||||
|
size: resp[0].storageStats?.size
|
||||||
|
}))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -29,11 +33,13 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
stats = {};
|
stats = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const res = this.mergeAnalyseResult({
|
const res = this.mergeAnalyseResult({
|
||||||
collections: [
|
collections: [
|
||||||
...collections.map((x, index) => ({
|
...collections.map((x, index) => ({
|
||||||
pureName: x.name,
|
pureName: x.name,
|
||||||
tableRowCount: stats[index]?.count,
|
tableRowCount: stats[index]?.count,
|
||||||
|
sizeBytes: stats[index]?.size,
|
||||||
uniqueKey: [{ columnName: '_id' }],
|
uniqueKey: [{ columnName: '_id' }],
|
||||||
partitionKey: [{ columnName: '_id' }],
|
partitionKey: [{ columnName: '_id' }],
|
||||||
clusterKey: [{ columnName: '_id' }],
|
clusterKey: [{ columnName: '_id' }],
|
||||||
|
|||||||
Reference in New Issue
Block a user