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。

1.4 KB
Raw Blame
import type { TreeNode } from "@/types/database";
import { hasTreeNodeDatabaseContext } from "@/lib/sidebar/treeNodeContext";
import { objectTypesForGroupNode } from "@/lib/table/tableTree";

export interface SidebarObjectGroupLoaders {
  loadTriggers(connectionId: string, database: string, table: string, schema?: string, nodeId?: string, catalog?: string): Promise<void>;
  loadObjectGroupChildren(node: TreeNode, options?: SidebarObjectGroupLoadOptions): Promise<void>;
}

export interface SidebarObjectGroupLoadOptions {
  searchFilter?: string;
  allowGlobalSearchMismatch?: boolean;
  expectedSidebarSearchQuery?: string;
}

/**
 * Loads object-group metadata from the same path used by the sidebar toggle.
 * Table trigger groups are special because they are scoped to one table;
 * schema-level trigger groups are regular database object groups.
 */
export async function loadSidebarObjectGroup(node: TreeNode, loaders: SidebarObjectGroupLoaders, options?: SidebarObjectGroupLoadOptions): Promise<boolean> {
  if (node.type === "group-triggers" && node.connectionId && hasTreeNodeDatabaseContext(node) && node.tableName) {
    await loaders.loadTriggers(node.connectionId, node.database, node.tableName, node.schema, node.id, node.catalog);
    return true;
  }

  if (!objectTypesForGroupNode(node.type)) return false;
  await loaders.loadObjectGroupChildren(node, options);
  return true;
}