Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix: support MongoDB Atlas SRV connections in form mode

t8y201c8072d97e3
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index 12a1e1ac6e..50ecbe6f50 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -2145,7 +2145,14 @@ function openExternalUrl(url: string) {
<div class="grid grid-cols-4 items-center gap-4">
<Label class="text-right">{{ t("connection.host") }}</Label>
<Input v-model="form.host" class="col-span-2" />
- <Input v-model.number="form.port" type="number" class="col-span-1" />
+ <Input v-model.number="form.port" type="number" class="col-span-1" :disabled="form.ssl" />
+ </div>
+ <div class="grid grid-cols-4 items-center gap-4">
+ <span />
+ <label class="col-span-3 flex items-center gap-2 text-sm">
+ <input type="checkbox" v-model="form.ssl" class="mr-0" />
+ <span>SRV (MongoDB Atlas)</span>
+ </label>
</div>
<div class="grid grid-cols-4 items-center gap-4">
<Label class="text-right">{{ t("connection.user") }}</Label>
diff --git a/crates/dbx-core/src/models/connection.rs b/crates/dbx-core/src/models/connection.rs
index cfbe621eb8..41257732de 100644
--- a/crates/dbx-core/src/models/connection.rs
+++ b/crates/dbx-core/src/models/connection.rs
@@ -405,7 +405,10 @@ impl ConnectionConfig {
suffix.push_str("&directConnection=true");
}
}
- format!("mongodb://{host}:{port}{db_part}{suffix}")
+ let scheme = if self.ssl { "mongodb+srv" } else { "mongodb" };
+ // SRV URLs resolve the port via DNS SRV records, so we omit the explicit port.
+ let addr = if self.ssl { host.to_string() } else { format!("{host}:{port}") };
+ format!("{scheme}://{addr}{db_part}{suffix}")
}
DatabaseType::Oracle => format!("oracle://{host}:{port}{db_part}"),
DatabaseType::Elasticsearch => {
@@ -508,10 +511,13 @@ impl ConnectionConfig {
suffix.push_str("&directConnection=true");
}
}
+ let scheme = if self.ssl { "mongodb+srv" } else { "mongodb" };
+ // SRV URLs resolve the port via DNS SRV records, so we omit the explicit port.
+ let addr = if self.ssl { host.to_string() } else { format!("{host}:{port}") };
if self.username.is_empty() {
- format!("mongodb://{host}:{port}{db_part}{suffix}")
+ format!("{scheme}://{addr}{db_part}{suffix}")
} else {
- format!("mongodb://{username}:{password}@{host}:{port}{db_part}{suffix}")
+ format!("{scheme}://{username}:{password}@{addr}{db_part}{suffix}")
}
}
DatabaseType::Oracle => {