解析)
dbx MongoDB 索引管理基于原生 listIndexes 的集合索引面板端到端實現(xiàn)解析【免費下載鏈接】dbx15MB輕量級跨平臺數(shù)據(jù)庫客戶端、數(shù)據(jù)庫管理工具。支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、DuckDB、ClickHouse、SQL Server 等。15MB, lightweight, cross-platform database client. Supports MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, ClickHouse, SQL Server and more.項目地址: https://gitcode.com/t8y2/dbx本文以 dbx 倉庫中 docs/mongo-index-management.md 為骨架結(jié)合源碼展開系統(tǒng)講解「仿 Navicat 的 MongoDB 集合索引管理面板」這一功能從前端MongoIndexManagerDialog.vue面板的索引創(chuàng)建表單唯一鍵/稀疏/TTL/部分過濾器/背景/存儲桶到后端 Rust 層用原生驅(qū)動listIndexes命令讀取完整索引規(guī)格MongoIndexSpec、Legacy Agent 降級路徑再到 Tauri 命令與 Web 路由的注冊以及編譯驗證、單元測試與回歸測試全流程。讀完本文你將掌握該功能在 dbx 中的完整調(diào)用鏈、數(shù)據(jù)結(jié)構(gòu)設(shè)計動機以及如何在自己機器上復現(xiàn)驗證過程。1. 功能總覽與進度狀態(tài)該功能的目標是在 dbx 桌面端為 MongoDB 集合提供與 Navicat 對齊的索引管理面板。根據(jù) docs/mongo-index-management.md 的進度記錄各部分完成狀態(tài)如下部分狀態(tài)前端集合右鍵 →「管理索引」菜單? 完成前端MongoIndexManagerDialog.vue面板列表 屬性區(qū)? 完成前端索引創(chuàng)建表單唯一鍵/稀疏/TTL/部分過濾器/背景/存儲桶大小? 完成前端i18nen / zh-CN / zh-TW? 完成前端單元測試4 個測試文件? 全部通過前端vue-tsc / oxlint / oxfmt? 全部通過后端Rust 源碼編寫驅(qū)動 ops Tauri 命令 Web 路由? 已寫完后端cargo check編譯驗證? 已通過整個功能橫跨三個層面前端 UI 層apps/desktop/src/components/sidebar/MongoIndexManagerDialog.vue新增以及SidebarTreeItemDialogs.vue、SidebarTreeRuntimeHost.vue、sidebarAsyncDialogs.ts、sidebarTreeDialogState.ts等側(cè)邊欄基礎(chǔ)設(shè)施的配合核心層crates/dbx-drivers/src/db/mongo_driver.rs新增MongoIndexKey/MongoIndexSpec結(jié)構(gòu)與讀取實現(xiàn)crates/dbx-core/src/query/mongo_ops.rs新增編排函數(shù)命令與路由層src-tauri/src/commands/mongo_cmd.rs的只讀 Tauri 命令與crates/dbx-web/src/routes/mongo.rs的 HTTP 路由。路徑說明文檔中記錄的crates/dbx-core/src/db/mongo_driver.rs在當前倉庫中實際位于crates/dbx-drivers/src/db/mongo_driver.rs驅(qū)動代碼集中在 dbx-drivers cratecrates/dbx-core/src/mongo_ops.rs實際為crates/dbx-core/src/query/mongo_ops.rs下文以實際倉庫路徑為準。2. 后端核心MongoIndexSpec數(shù)據(jù)結(jié)構(gòu)的設(shè)計動機MongoDB 的索引選項遠多于通用關(guān)系型數(shù)據(jù)庫sparse稀疏、expireAfterSecondsTTL、background后臺構(gòu)建、bucketSizegeoHaystack 存儲桶等這些字段在 dbx 共享的通用IndexInfo結(jié)構(gòu)中都無處安放。因此索引管理功能必須讀取 MongoDB 專屬的數(shù)據(jù)形狀。2.1 結(jié)構(gòu)體定義源碼位于 crates/dbx-drivers/src/db/mongo_driver.rs兩個結(jié)構(gòu)體分工明確/// One key of a MongoDB index, with the direction/type kept as the server reports it /// (1, -1, text, 2dsphere, hashed, …). #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct MongoIndexKey { pub field: String, pub direction: String, } /// Full MongoDB index specification straight from listIndexes. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct MongoIndexSpec { pub name: String, pub keys: VecMongoIndexKey, pub is_unique: bool, pub is_primary: bool, pub is_sparse: bool, /// TTL in seconds; None when the index does not expire. pub expire_after_seconds: Optioni64, /// Partial index condition, serialized as JSON. pub partial_filter_expression: OptionString, /// Ignored by MongoDB 4.2, still reported by older servers. pub background: bool, /// Only meaningful for geoHaystack indexes, removed in MongoDB 4.4. pub bucket_size: Optioni64, pub hidden: bool, /// false when the properties above could not be read (Legacy Agent fallback), /// so callers can avoid presenting defaults as if the server had reported them. pub properties_complete: bool, /// Options this build does not model, serialized as JSON for display only. pub extra_options: OptionString, }幾個設(shè)計要點值得關(guān)注MongoIndexKey.direction保留服務(wù)器原值1、-1是排序方向而text、2dsphere、hashed是索引類型。結(jié)構(gòu)體注釋明確說明 direction 按服務(wù)器報告的原樣保留前端據(jù)此區(qū)分普通升/降序索引與特殊類型索引properties_complete標志位這是全功能最關(guān)鍵的設(shè)計。當后端走 Legacy Agent 降級路徑、無法讀取完整選項集時置為false前端據(jù)此隱藏稀疏/TTL/背景/存儲桶等字段避免把后端讀不到的值當作服務(wù)器真實值展示extra_options兜底MODELED_INDEX_FIELDS常量見 mongo_driver.rs列出本構(gòu)建顯式建模的字段name、key、v、ns、unique、sparse、expireAfterSeconds、partialFilterExpression、background、bucketSize、hidden其余字段如collation、wildcardProjection、weights統(tǒng)一落入extra_options以 JSON 形式僅作展示保證信息不丟失。2.2 為什么不用Collection::list_indexes源碼注釋mongo_driver.rs給出了明確理由// Raw command rather than Collection::list_indexes, whose IndexModel drops // sparse/TTL/background. The driver cursor owns getMore and killCursors.驅(qū)動提供的IndexModel會丟棄稀疏/TTL/背景等信息因此實現(xiàn)直接向數(shù)據(jù)庫下發(fā)原始listIndexes命令游標自行管理getMore與killCursorspub async fn list_index_specs( client: Client, database: str, collection: str, ) - ResultVecMongoIndexSpec, String { let database validate_mongo_namespace_name(database, Database)?; let collection validate_mongo_namespace_name(collection, Collection)?; let mut cursor client .database(database) .run_cursor_command(doc! { listIndexes: collection }) .await .map_err(|e| e.to_string())?; let mut specs Vec::new(); while let Some(document) cursor.try_next().await.map_err(|e| e.to_string())? { specs.push(index_spec_from_document(document)); } Ok(specs) }這里用到的Database::run_cursor_command(Document)簽名與同文件aggregate_documentsdb.run_cursor_command(command)cursor.try_next()流式讀取完全一致依賴futures::TryStreamExt文件第 14 行已 import屬于倉庫內(nèi)已有、被反復驗證過的 API 用法。3. 解析邏輯從 BSON 文檔到MongoIndexSpec3.1index_spec_from_document原生驅(qū)動主路徑定義在 mongo_driver.rs負責把listIndexes返回的每一條 BSON 文檔映射為MongoIndexSpec。映射過程中有三個值得展開的輔助函數(shù)index_key_direction—— 方向規(guī)范化L983-L991fn index_key_direction(value: Bson) - String { match value { Bson::String(value) value.clone(), Bson::Int32(value) value.to_string(), Bson::Int64(value) value.to_string(), Bson::Double(value) if value.fract() 0.0 value.is_finite() (*value as i64).to_string(), value value.to_string(), } }MongoDB 服務(wù)器可能把1報告為Int32(1)或Double(1.0)該函數(shù)把整數(shù)值Double規(guī)范化為1保證下游比較一致非數(shù)字方向text、2dsphere按字符串原樣保留。index_flag—— 布爾/真值寬容解析L994-L1002MongoDB 對索引標志位既接受布爾也接受真值數(shù)字函數(shù)對Boolean、Int32、Int64、Double均按非零即真的規(guī)則處理。index_number—— TTL 與存儲桶的數(shù)值解析L1005-L1012expireAfterSeconds/bucketSize在不同服務(wù)器版本下可能以Int32、Int64或Double到達統(tǒng)一收窄為Optioni64。映射規(guī)則細節(jié)name 兜底生成若服務(wù)器省略name或為空串按field_direction拼接生成如{ email: 1, createdAt: -1 }推導為email_1_createdAt_-1is_primary判定name _id_即為默認_id索引且主索引同時強制is_unique trueindex_flag(document, unique) || is_primarypartialFilterExpression序列化以bson_to_json轉(zhuǎn)成 JSON 字符串供前端展示/編輯extra_optionsMODELED_INDEX_FIELDS之外的字段收集為 JSON 展示字符串。3.2index_spec_from_index_infoLegacy Agent 降級路徑定義在 mongo_driver.rs把共享的IndexInfo降級轉(zhuǎn)換為MongoIndexSpec優(yōu)先從info.index_type形如email:1,createdAt:-1的逗號分隔字符串解析 keys每個片段用rsplit_once(:)切分字段與方向切分失敗或無 index_type 時回退到info.columns平鋪字段稀疏/TTL/背景/存儲桶/隱藏一律置默認值partial_filter_expression透傳info.filter核心語義properties_complete: false明確告知前端這些屬性并非服務(wù)器真實報告值。正如源碼注釋所言Degrade a shared IndexInfo into a spec for drivers that cannot report the full option set.properties_completestaysfalseso nothing is presented as server truth that was never read.3.3mongo_list_index_specs_core雙路徑編排定義在 crates/dbx-core/src/query/mongo_ops.rs是后端讀取索引的唯一入口pub async fn mongo_list_index_specs_core( state: AppState, connection_id: str, database: str, collection: str, ) - ResultVecmongo_driver::MongoIndexSpec, String { mongo_driver::validate_mongo_namespace_name(database, Database)?; mongo_driver::validate_mongo_namespace_name(collection, Collection)?; ensure_document_pool(state, connection_id).await?; let is_native { /* 判斷 PoolKind::MongoDb 還是 PoolKind::Agent */ }; if !is_native { // list_indexes_core owns the agent metadata session, so borrow nothing here. let indexes crate::schema::list_indexes_core(state, connection_id, database, database, collection).await?; return Ok(indexes.iter().map(mongo_driver::index_spec_from_index_info).collect()); } let pool state.pool_handle(connection_id).await.ok_or(Not found)?; match pool { PoolKind::MongoDb(client) mongo_driver::list_index_specs(client, database, collection).await, _ Err(Not a MongoDB connection.to_string()), } }要點連接池判定PoolKind::MongoDb(_)走原生驅(qū)動PoolKind::Agent(_)走 Legacy Agent 降級其他類型直接報錯 Not a MongoDB connectionLegacy Agent 路徑的簽名語義調(diào)用crate::schema::list_indexes_core(state, connection_id, database, database, collection)即「庫即 schema」——MongoDB 的 database 同時充當 schema 參數(shù)collection 充當 table 參數(shù)與schema.rs中l(wèi)ist_indexes_core(state: AppState, connection_id: str, database: str, schema: str, table: str)的定義簽名一一對應(yīng)會話所有權(quán)注意注釋特別說明list_indexes_core內(nèi)部擁有 agent metadata session故此處不借用任何東西。4. 命令層與路由層Tauri Web 雙通道4.1 Tauri 只讀命令新增只讀 Tauri 命令mongo_list_index_specs定義于 src-tauri/src/commands/mongo_cmd.rs僅透傳給核心層pub async fn mongo_list_index_specs( state: tauri::State_, AppState, connection_id: String, database: String, collection: String, ) - ResultVecMongoIndexSpec, String { dbx_core::mongo_ops::mongo_list_index_specs_core(state, connection_id, database, collection).await }該命令在 src-tauri/src/lib.rs約 1808 行注冊于tauri::generate_handler![...]宏內(nèi)與相鄰的mongo_create_index1809/mongo_drop_indexes1810同屬一個宏調(diào)用作用域。命名上讀操作為mongo_list_index_specs只讀寫操作為mongo_create_index/mongo_drop_indexes職責邊界清晰。4.2 Web 路由crates/dbx-web/src/routes/mongo.rs 新增只讀 handlerlist_index_specsPOSTensure_scope讀策略返回VecMongoIndexSpec并在 crates/dbx-web/src/main.rs約 620 行注冊.route(/mongo/list-index-specs, post(routes::mongo::list_index_specs))該路徑是獨立路由與既有的create-index/drop-indexes不沖突handler 不帶寫策略守衛(wèi)符合只讀語義。4.3 前端 API 層三層封裝前端把「Tauri 桌面通道」與「HTTP 通道」統(tǒng)一收斂到api.tsapps/desktop/src/lib/backend/tauri.tsmongoListIndexSpecs(connectionId, database, collection)→invoke(mongo_list_index_specs, ...)apps/desktop/src/lib/backend/http.ts同一簽名 →POST /api/mongo/list-index-specsapps/desktop/src/lib/backend/api.tsexport const mongoListIndexSpecs forward(mongoListIndexSpecs)按運行環(huán)境自動轉(zhuǎn)發(fā)到上述任一實現(xiàn)。類型MongoIndexSpec/MongoIndexKey定義在tauri.ts并被http.tsimport保證兩個通道的類型一致。4.4 Legacy Agent 降級的前端呈現(xiàn)這是文檔第 4 節(jié)特別強調(diào)的有意設(shè)計當連接為 Legacy Agent 時返回properties_complete: false面板中稀疏/TTL/背景/存儲桶字段會隱藏只顯示「使用原生驅(qū)動連接以查看…」提示。原因正如 mongo_ops.rs 注釋所述Legacy Agent 沒有等價方法降級到通用索引列表并用properties_complete: false標記避免把后端讀不到的值當作服務(wù)器真實值展示。5. 編譯驗證從「無法編譯」到全綠5.1 歷史根因與復查結(jié)論該功能曾在本機遇到cargo編譯失敗報錯為rust-lld: error: could not open kernel32.lib: no such file or directory could not open kernel32.lib / ntdll.lib / userenv.lib / ws2_32.lib / dbghelp.lib初次診斷懷疑缺少 VS / Windows SDKC:\Program Files (x86)\Windows Kits\10\Lib、C:\Program Files\Microsoft Visual Studio、C:\mingw64/C:\msys64均未找到且工具鏈只有stable-x86_64-pc-windows-msvc。但復查2026-08-13推翻了該診斷Windows 10 SDK 實際已安裝在C:/Program Files (x86)/Windows Kits/10/Lib/{10.0.26100.0, 10.0.28000.0}MSVC 鏈接器也在 PATH/d/dev/ms/soft/VC/Tools/MSVC/14.51.36231/bin/Hostx64/x64。真正的根因是~/.cargo/bin不在 PATH 中加入后cargo check/cargo test即可運行。若在其他機器復現(xiàn)該問題解決方式任選其一安裝Visual Studio Build Tools勾選「使用 C 的桌面開發(fā)」 Windows 10/11 SDK或在有 SDK 的機器 / CI上跑cargo test -p dbx-core --lib mongo_driver::。5.2 完整驗證命令序列文檔 §3 記錄了逐條執(zhí)行的驗證命令# 1. 編譯 dbx-core cargo check -p dbx-core --lib # 2. 跑新增的驅(qū)動單測9 個 cargo test -p dbx-core --lib mongo_driver::index_spec_ # 3. 編譯 Tauri 命令層 cargo check --manifest-path src-tauri/Cargo.toml # 4. 編譯 Web 路由層 cargo check -p dbx-web實際執(zhí)行時cargo 1.97.1/stable-x86_64-pc-windows-msvcMSVC 14.51 Windows 10 SDK 10.0.26100.0 / 10.0.28000.0因本機perl是 MSYS2 版、缺Locale/Maketext/Simple.pm導致 OpenSSL Configure 失敗需以--no-default-features繞開sqlite-sqlcipher其libsqlite3-sys觸發(fā)openssl-sys源碼編譯# 步驟 1編譯 dbx-core $ cargo check -p dbx-core --lib --no-default-features \ --features duckdb-sidecar,mq-admin,system-fonts Finished dev profile in 1m 08s # 步驟 2編譯 dbx-web同上 --no-default-features 跳過 sqlcipher $ cargo check -p dbx-web --no-default-features Finished dev profile in 29.16s # 步驟 3編譯 Tauri 命令層 $ (cd src-tauri cargo check --no-default-features \ --features duckdb-sidecar,mq-admin,system-fonts) Finished dev profile in 9m 50s # 步驟 4跑 mongo_driver 單測含 9 個新增 index_spec_ 用例 $ cargo test -p dbx-core --lib --no-default-features \ --features duckdb-sidecar,mq-admin,system-fonts mongo_driver:: test result: ok. 97 passed; 0 failed; 0 ignored注意--no-default-features僅為繞開本機 OpenSSL 環(huán)境問題不是本次索引功能改動引入的問題——sqlcipher默認 feature 一直依賴 vendored OpenSSL與mongo_index_specs的任何代碼無關(guān)。在裝有 Strawberry Perl / 完整 MSYS2 或預(yù)編譯 OpenSSL 的 CI 上跑默認 features 即可。編譯期僅遺留兩條與本次改動無關(guān)的預(yù)存 warning已通過git stash在 HEAD 上單獨復現(xiàn)確認非本次引入crates/dbx-core/src/db/agent_driver.rs:3093unused import: spawn_agent_processcrates/dbx-core/src/mongo_ops.rs:677unused import: super::*僅#[cfg(test)]模塊#[cfg(unix)]用例在 Windows 上不編譯所致5.3 四項人工復核點編譯驗證之外文檔列出了需要人工重點復核的 4 項均已通過mongo_driver.rs::list_index_specs中client.database(database).run_cursor_command(doc! { listIndexes: collection })的 API 用法與同文件的aggregate_documentsdb.run_cursor_command(command)cursor.try_next()流式讀取完全一致簽名同為Database::run_cursor_command(Document)futures::TryStreamExt已 importmongo_ops.rs對crate::schema::list_indexes_core的調(diào)用簽名(state, connection_id, database, database, collection)與定義一致Mongo 的庫即 schema 語義Legacy Agent 降級時正確寫出properties_complete: falsesrc-tauri/src/lib.rs命令注冊位于generate_handler!宏的正確作用域內(nèi)與mongo_create_index/mongo_drop_indexes相鄰crates/dbx-web/src/main.rs的路由注冊無歧義沖突。6. 單元測試9 個index_spec_*用例新增的 9 個驅(qū)動單測全部定義在 crates/dbx-drivers/src/db/mongo_driver.rs 的#[cfg(test)]模塊中覆蓋了解析邏輯的主要邊界測試用例驗證點index_spec_from_document_reports_every_modeled_property每個已建模屬性unique/sparse/expireAfterSeconds/background/bucketSize/hidden都被正確讀出index_spec_from_document_canonicalizes_whole_doubles_and_marks_the_default_index整數(shù)值 Double 方向被規(guī)范化為1且_id_索引被標記為 primaryindex_spec_from_document_keeps_non_numeric_key_directions_literaltext、2dsphere等非數(shù)字方向原樣保留index_spec_from_document_accepts_numeric_truthiness_for_flags標志位接受布爾與真值數(shù)字兩種形式index_spec_from_document_collects_unmodeled_options_without_losing_them未建模選項落入extra_options不丟失index_spec_from_document_derives_a_name_when_the_server_omits_it服務(wù)器省略 name 時按field_direction拼接兜底index_spec_from_document_reads_int64_and_double_ttl_valuesTTL 值支持 Int64 與 Double 兩種 BSON 數(shù)值類型index_spec_from_index_info_marks_properties_as_incomplete降級路徑正確置properties_complete: falsekey 方向解析正確index_spec_from_index_info_falls_back_to_columns_without_an_index_type無 index_type 時回退到columns平鋪字段這些用例從不同 BSON 輸入形態(tài)布爾/數(shù)字真值、Int32/Int64/Double 數(shù)值、字符串方向、缺省 name、未建模字段驗證了第 3 節(jié)描述的全部規(guī)范化邏輯。7. 前端回歸測試基準全綠前端回歸測試命令如下對應(yīng)文檔 §5node node_modules/vitest/vitest.mjs run \ apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts \ apps/desktop/src/lib/sidebar/__tests__/mongoCollectionMutation.spec.ts \ packages/app-tests/productionGuardEntrypoints.test.ts \ apps/desktop/src/components/sidebar/__tests__/SidebarTreeItemDialogs.mongoIndex.spec.ts node node_modules/vue-tsc/bin/vue-tsc.js --noEmit --project apps/desktop/tsconfig.json記錄到的基線結(jié)果全量vitest run6996 / 6997 通過唯一失敗windowsInstallerTemplate.spec.ts為預(yù)存在問題與本次改動無關(guān)已在git stash后單獨復現(xiàn)vue-tsc --noEmit類型檢查通過額外注意packages/app-tests里沒有mongoListIndexSpecs的 guard 測試前端新增的 API forward 不受現(xiàn)有守衛(wèi)約束影響。8. 已知取舍與后續(xù)可做文檔 §6 明確記錄了功能邊界與后續(xù)方向項說明background/bucketSizeMongoDB 4.2 忽略 background、4.4 移除 geoHaystack 后 bucketSize 失效——面板已標注「兼容選項」hidden索引后端已透傳并在面板顯示但新建表單未提供hidden 開關(guān)createIndexes支持hidden可后續(xù)加字段 datalist 補全依賴listMongoCompletionFields采樣MongoDB 無 schema空集合無建議部分過濾器校驗前端只做 JSON 合法性校驗結(jié)構(gòu)合理性交給服務(wù)器從源碼看MongoIndexSpec.hidden字段在原生驅(qū)動路徑中確實被讀取并透傳mongo_driver.rs 的hidden: index_flag(document, hidden)僅創(chuàng)建表單尚未暴露開關(guān)符合文檔描述。9. 本次改動文件清單文檔 §7 記錄的全部改動文件按層歸納Rust 側(cè)均已完成編譯/測試驗證前端新增/修改apps/desktop/src/components/sidebar/MongoIndexManagerDialog.vue新增apps/desktop/src/components/sidebar/SidebarTreeItemDialogs.vueapps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vueapps/desktop/src/components/sidebar/sidebarAsyncDialogs.tsapps/desktop/src/components/sidebar/sidebarTreeDialogState.tsapps/desktop/src/composables/useSidebarDatabaseSpecificMutationRuntime.tsapps/desktop/src/lib/sidebar/mongoCollectionMutation.tsapps/desktop/src/lib/backend/api.ts/http.ts/tauri.tsapps/desktop/src/i18n/locales/en.ts/zh-CN.ts/zh-TW.ts前端測試apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.tsapps/desktop/src/lib/sidebar/__tests__/mongoCollectionMutation.spec.ts后端 Rust已編譯/測試通過crates/dbx-drivers/src/db/mongo_driver.rs新增結(jié)構(gòu)體、list_index_specs、兩個映射函數(shù)、輔助函數(shù)、9 個單測crates/dbx-core/src/query/mongo_ops.rsmongo_list_index_specs_core雙路徑編排src-tauri/src/commands/mongo_cmd.rs只讀 Tauri 命令src-tauri/src/lib.rs命令注冊crates/dbx-web/src/routes/mongo.rsWeb 路由 handlercrates/dbx-web/src/main.rs路由注冊10. 總結(jié)一條完整的功能鏈路MongoDB 索引管理功能在 dbx 中的完整鏈路為集合右鍵「管理索引」→ MongoIndexManagerDialog.vue → api.mongoListIndexSpecsforward 按環(huán)境分派 ├─ Tauri 通道: invoke(mongo_list_index_specs) │ └─ mongo_cmd.rs → mongo_ops::mongo_list_index_specs_core └─ HTTP 通道: POST /api/mongo/list-index-specs └─ routes::mongo::list_index_specsensure_scope 讀策略 → 同上 core 函數(shù) ├─ 原生連接: list_index_specs → run_cursor_command(listIndexes) → index_spec_from_document └─ Legacy Agent: schema::list_indexes_core → index_spec_from_index_infoproperties_complete: false設(shè)計上的兩個關(guān)鍵決策貫穿全鏈路信息不丟失優(yōu)先于接口統(tǒng)一寧可新增 MongoDB 專屬的MongoIndexSpec結(jié)構(gòu)也不把稀疏/TTL/背景/存儲桶等信息塞進無法承載它們的通用IndexInfo未建模字段繼續(xù)用extra_optionsJSON 兜底展示誠實呈現(xiàn)數(shù)據(jù)來源properties_complete標志位貫穿降級路徑讓前端永遠不把「讀不到的值」當作「服務(wù)器的真實值」展示——這正是該功能在 Legacy Agent 連接上只顯示降級提示而非偽造默認值的根本原因。如果你在本機復現(xiàn)建議從cargo test -p dbx-core --lib mongo_driver::9 個新增單測與第 7 節(jié)的前端回歸命令入手再按第 5.2 節(jié)的命令序列完成全鏈路編譯驗證?!久赓M下載鏈接】dbx15MB輕量級跨平臺數(shù)據(jù)庫客戶端、數(shù)據(jù)庫管理工具。支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、DuckDB、ClickHouse、SQL Server 等。15MB, lightweight, cross-platform database client. Supports MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, ClickHouse, SQL Server and more.項目地址: https://gitcode.com/t8y2/dbx創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考