mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 16:24:33 +00:00
feat(connection): 支持设置默认数据库
统一新建查询的默认数据库选择逻辑,减少重复手动选择。
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import type { ConnectionConfig } from "@/types/database";
|
||||
|
||||
export function resolveDefaultDatabase(connection: Pick<ConnectionConfig, "database">, options: string[]): string {
|
||||
return connection.database || options[0] || "";
|
||||
}
|
||||
|
||||
export function isDefaultDatabase(
|
||||
connection: Pick<ConnectionConfig, "database"> | undefined,
|
||||
database: string,
|
||||
): boolean {
|
||||
return !!connection?.database && !!database && connection.database === database;
|
||||
}
|
||||
Reference in New Issue
Block a user