feat(mongodb): support collection stats shell commands
Add db.coll.stats() / dataSize() / storageSize(scale) / totalIndexSize() so these MongoDB shell commands return a result grid instead of the "Use MongoDB shell-style commands" error (issue #2529). - backend: collStats via mongo_driver.collection_stats, wired through mongo_ops, the dbx-web /mongo/collection-stats route, the tauri mongo_collection_stats command, and the MCP data bridge - node-core: parseMongoCollectionStatsCommand + result formatter and executeQuery dispatch (web build + MCP path) - desktop: mirror the parser/executor/autocomplete in mongoShellCommand.ts, queryStore.ts, api/tauri/http facade, and mongoCompletion.ts - tests for the parser, result formatter, and completion entries Close #2529
This commit is contained in:
1 parent
a0e9acce95
commit
91c77e53c4
18 files changed
+518
-5
No files matched your search
@@ -11,6 +11,7 @@ import { ACTIVE_TAB_STORAGE_KEY, OPEN_TABS_STORAGE_KEY, restoreOpenTabsState, se
|
||||
import {
|
||||
evaluateMongoAggregateSafety,
|
||||
evaluateMongoWriteSafety,
|
||||
mongoCollectionStatsToQueryResult,
|
||||
mongoCountToQueryResult,
|
||||
mongoCreateIndexToQueryResult,
|
||||
mongoDocumentsToQueryResult,
|
||||
@@ -1996,6 +1997,25 @@ export const useQueryStore = defineStore("query", () => {
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "collectionStats": {
|
||||
console.info("[DBX][executeTabSql:mongo-collection-stats:start]", {
|
||||
traceId,
|
||||
collection: mongoCommand.collection,
|
||||
metric: mongoCommand.metric,
|
||||
database: currentDatabase,
|
||||
});
|
||||
const stats = await api.mongoCollectionStats(tab.connectionId, currentDatabase, mongoCommand.collection, mongoCommand.scale, executionId);
|
||||
allResults.push(markQueryResultRowsRaw(mongoCollectionStatsToQueryResult(mongoCommand.metric, stats as unknown as Record<string, unknown>, performance.now() - commandStartedAt)));
|
||||
mongoEditTarget = undefined;
|
||||
console.info("[DBX][executeTabSql:mongo-collection-stats:done]", {
|
||||
traceId,
|
||||
collection: mongoCommand.collection,
|
||||
metric: mongoCommand.metric,
|
||||
database: currentDatabase,
|
||||
elapsed: elapsed(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "insert":
|
||||
case "update":
|
||||
case "delete":
|
||||
|
||||
Reference in new issue
Block a user