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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import { normalizeVisibleSchemaSelection } from "@/lib/database/visibleDatabases";
export type VisibleSchemaSaveAction = { type: "none" } | { type: "clear" } | { type: "set"; schemaNames: string[] };
export function initialVisibleSchemaSelection(schemaNames: string[], configured: string[] | undefined, emptySelectionMeansAll = false): Set<string> {
if (configured === undefined || (emptySelectionMeansAll && configured.length === 0)) return new Set(schemaNames);
return new Set(normalizeVisibleSchemaSelection(configured, schemaNames));
}
export function selectVisibleSchemas(schemaNames: string[]): Set<string> {
return new Set(schemaNames);
}
export function addVisibleSchemas(selection: Set<string>, schemaNames: string[]): Set<string> {
const next = new Set(selection);
for (const name of schemaNames) next.add(name);
return next;
}
export function resolveVisibleSchemaSaveAction(selection: Set<string>, schemaNames: string[], configured: string[] | undefined): VisibleSchemaSaveAction {
const normalized = normalizeSelectionInSchemaOrder(selection, schemaNames);
const availableCount = new Set(schemaNames).size;
if (normalized.length === availableCount) {
return configured ? { type: "clear" } : { type: "none" };
}
if (configured && sameSelection(normalized, normalizeVisibleSchemaSelection(configured, schemaNames))) {
return { type: "none" };
}
return { type: "set", schemaNames: normalized };
}
function normalizeSelectionInSchemaOrder(selection: Set<string>, schemaNames: string[]): string[] {
return normalizeVisibleSchemaSelection(
schemaNames.filter((name) => selection.has(name)),
schemaNames,
);
}
function sameSelection(left: string[], right: string[]): boolean {
if (left.length !== right.length) return false;
const rightSet = new Set(right);
return left.every((name) => rightSet.has(name));
}