fix(mongodb): support getIndexes shell command

This commit is contained in:
t8y2 committed 2026-06-08 01:25:44 +08:00
1 parent fabf2172e4
commit a5659d7637
8 files changed
+199 -2

No files matched your search

+28
View File
@@ -18,10 +18,12 @@ import {
evaluateMongoAggregateSafety,
mongoCountToQueryResult,
mongoDocumentsToQueryResult,
mongoIndexesToQueryResult,
mongoWriteToQueryResult,
parseMongoAggregateCommand,
parseMongoCountDocumentsCommand,
parseMongoFindCommand,
parseMongoGetIndexesCommand,
parseMongoWriteCommand,
type MongoAggregateSafetyOptions,
} from "@/lib/mongoShellCommand";
@@ -1091,6 +1093,32 @@ export const useQueryStore = defineStore("query", () => {
return;
}
const mongoGetIndexes = conn?.db_type === "mongodb" ? parseMongoGetIndexesCommand(sql) : null;
if (mongoGetIndexes) {
await connStore.ensureConnected(tab.connectionId);
console.info("[DBX][executeTabSql:mongo-indexes:start]", { traceId, collection: mongoGetIndexes.collection });
const indexes = await api.listIndexes(tab.connectionId, tab.database, "", mongoGetIndexes.collection);
console.info("[DBX][executeTabSql:mongo-indexes:done]", {
traceId,
indexCount: indexes.length,
elapsed: elapsed(),
});
const current = tabs.value.find((t) => t.id === id);
if (current?.executionId === executionId) {
current.results = undefined;
current.activeResultIndex = undefined;
current.result = markQueryResultRowsRaw(mongoIndexesToQueryResult(indexes, performance.now() - startedAt));
touchResult(current);
current.queryAnalysis = undefined;
current.querySourceColumns = undefined;
current.queryEditabilityReason = undefined;
current.tableMeta = undefined;
current.resultBaseSql = options?.resultBaseSql ?? sql;
current.resultSortedSql = options?.resultSortedSql;
}
return;
}
const mongoWrite = conn?.db_type === "mongodb" ? parseMongoWriteCommand(sql) : null;
if (mongoWrite) {
await connStore.ensureConnected(tab.connectionId);