fix(mongodb): support shell projection and db.version
This commit is contained in:
1 parent
44011cb9a4
commit
7a5984a1fd
24 files changed
+390
-38
No files matched your search
@@ -14,14 +14,16 @@ import {
|
||||
mongoCountToQueryResult,
|
||||
mongoDocumentsToQueryResult,
|
||||
mongoIndexesToQueryResult,
|
||||
mongoWriteToQueryResult,
|
||||
mongoUseToQueryResult,
|
||||
mongoVersionToQueryResult,
|
||||
mongoWriteToQueryResult,
|
||||
parseMongoAggregateCommand,
|
||||
parseMongoCountDocumentsCommand,
|
||||
parseMongoFindCommand,
|
||||
parseMongoGetIndexesCommand,
|
||||
parseMongoWriteCommand,
|
||||
parseMongoUseCommand,
|
||||
parseMongoVersionCommand,
|
||||
type MongoAggregateSafetyOptions,
|
||||
} from "@/lib/mongoShellCommand";
|
||||
import { redisCommandResultToQueryResult } from "@/lib/redisQueryResult";
|
||||
@@ -1589,7 +1591,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
if (mongoFind) {
|
||||
await connStore.ensureConnected(tab.connectionId);
|
||||
console.info("[DBX][executeTabSql:mongo-find:start]", { traceId, collection: mongoFind.collection });
|
||||
const result = await api.mongoFindDocuments(tab.connectionId, tab.database, mongoFind.collection, mongoFind.skip, mongoFind.limit, mongoFind.filter, mongoFind.sort, executionId);
|
||||
const result = await api.mongoFindDocuments(tab.connectionId, tab.database, mongoFind.collection, mongoFind.skip, mongoFind.limit, mongoFind.filter, mongoFind.projection, mongoFind.sort, executionId);
|
||||
console.info("[DBX][executeTabSql:mongo-find:done]", {
|
||||
traceId,
|
||||
rowCount: result.documents.length,
|
||||
@@ -1613,11 +1615,38 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
return;
|
||||
}
|
||||
const mongoVersion = conn?.db_type === "mongodb" ? parseMongoVersionCommand(sql) : null;
|
||||
if (mongoVersion) {
|
||||
await connStore.ensureConnected(tab.connectionId);
|
||||
console.info("[DBX][executeTabSql:mongo-version:start]", { traceId });
|
||||
const version = await api.mongoServerVersion(tab.connectionId, tab.database, executionId);
|
||||
console.info("[DBX][executeTabSql:mongo-version:done]", {
|
||||
traceId,
|
||||
version,
|
||||
elapsed: elapsed(),
|
||||
});
|
||||
const current = tabs.value.find((t) => t.id === id);
|
||||
if (current?.executionId === executionId) {
|
||||
current.results = undefined;
|
||||
current.activeResultIndex = undefined;
|
||||
current.result = markQueryResultRowsRaw(mongoVersionToQueryResult(version, performance.now() - startedAt));
|
||||
touchResult(current);
|
||||
current.queryAnalysis = undefined;
|
||||
current.querySourceColumns = undefined;
|
||||
current.queryEditabilityReason = undefined;
|
||||
current.mongoEditTarget = undefined;
|
||||
current.tableMeta = undefined;
|
||||
current.resultBaseSql = options?.resultBaseSql ?? sql;
|
||||
current.resultSortedSql = options?.resultSortedSql;
|
||||
syncDisplayedResultRun(current, options?.resultBaseSql ?? sql);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const mongoCount = conn?.db_type === "mongodb" ? parseMongoCountDocumentsCommand(sql) : null;
|
||||
if (mongoCount) {
|
||||
await connStore.ensureConnected(tab.connectionId);
|
||||
console.info("[DBX][executeTabSql:mongo-count:start]", { traceId, collection: mongoCount.collection });
|
||||
const result = await api.mongoFindDocuments(tab.connectionId, tab.database, mongoCount.collection, 0, 1, mongoCount.filter, undefined, executionId);
|
||||
const result = await api.mongoFindDocuments(tab.connectionId, tab.database, mongoCount.collection, 0, 1, mongoCount.filter, undefined, undefined, executionId);
|
||||
console.info("[DBX][executeTabSql:mongo-count:done]", {
|
||||
traceId,
|
||||
total: result.total,
|
||||
|
||||
Reference in new issue
Block a user