feat(cli): migrate CLI to native Rust binary

This commit is contained in:
t8y2 committed 2026-07-18 22:29:29 +08:00
1 parent fa5579a3f1
commit 4bcf618162
47 files changed
+2369 -1255

No files matched your search

@@ -90,6 +90,20 @@ export type MongoCommand =
export type MongoWriteCommand = Extract<MongoCommand, { kind: MongoWriteKind }>;
export function normalizeRustMongoCommand(raw: Record<string, unknown>): MongoCommand {
const command = Object.fromEntries(Object.entries(raw).filter(([, value]) => value !== null)) as Record<string, any>;
if (command.kind === "countDocuments") {
const { accurate, ...rest } = command;
return { ...rest, kind: "countDocuments", mode: accurate ? "accurate" : "legacy" } as MongoCommand;
}
if (command.kind === "dropIndexes") {
const { single, indexes, ...rest } = command;
if (single) return { ...rest, kind: "dropIndex", index: indexes } as MongoCommand;
return { ...rest, kind: "dropIndexes", ...(indexes ? { indexes } : {}) } as MongoCommand;
}
return command as MongoCommand;
}
export interface ParsedMongoCommand {
text: string;
command: MongoCommand;