npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gingkoo/pandora-metabase

v1.0.64

Published

## 功能概述

Readme

Pandora-Metabase 使用指南

功能概述

Pandora-Metabase 是一个用于动态生成 SQL 查询的工具库,支持通过可视化界面配置表结构、字段及查询逻辑。

主要功能

  • 动态获取表字段:使用 getColumns 方法可以动态获取指定表的最新字段信息。
  • 可视化 SQL 构建:通过 MetaBase 组件,用户能够以图形化的方式构建 SQL 查询,支持多种元数据类型,如 MetaData, MetaJoin, MetaFilter 等。
  • 灵活扩展:提供了丰富的接口和类型定义,便于根据具体需求进行定制和扩展。

类型定义

export type MetaListType = 
  | MetaData 
  | MetaJoin 
  | MetaCustom 
  | MetaFilter 
  | MetaSummarize 
  | MetaSort 
  | MetaLimit;

// Columns 集合
export interface MetaData_ColumnsType {
  name: string; // 字段名
  name_zh: string; // 字段中文名称
  database_type: SQL_COLUMN_TYPE | string; // 数据库中的字段类型
  special_type: SpecialType | string; // 特殊类型,如主键、外键等
  select: boolean; // 是否在查询中选中该字段
}
export type ToolbarType =
  | 'filter'
  | 'summarize'
  | 'joinData'
  | 'permissionTable'
  | 'customColumn'
  | 'sort'
  | 'rowLimit'
  | 'union';  //展示合并结果集,会变为多个数组

export interface MetaBaseProps {
	/**
	 * 工具栏列表
	 * 默认 ['filter','summarize','joinData','permissionTable','customColumn','sort','rowLimit']
	 */
  loading?: boolean;
  btnText?: string;
  showFields?: boolean; // 显示字段
  readonly?: boolean;
  getTables: (datasourceId: string) => Promise<any>;
  getColumns: (table: { name: string; [key: string]: any }, datasourceId: string) => Promise<any>;
  toolbar?: ToolbarType[];
  subToolbar?: ToolbarType[]; //子查询功能菜单 默认取toolbar
  tableNameTpl?: string; //表名
  fieldNameTpl?: string; //字段名
  onOk?: (params: any) => void;
  value?: MetaListType[]; //默认值
  sourceList?: DatasourceType[];
  showSubquery?: boolean; //是否展示子查询
  subShowSubquery?: boolean; //子查询是否展示子查询
  constantList?: OptionItem[]; //常量下拉框
  notExistsToolbar?: ToolbarType[]; // notExists的功能菜单 默认取toolbar
  ignoreGroupByType?: boolean; // 忽略groupBy类型

}

export interface OptionItem {
  value?: string;
  label: string;
  icon?: React.ReactNode;
}

export interface SqlVisionBuilderRef {
  setDatasource: (list: DatasourceType[]) => void; // 设置数据源列表
  setPreData: (data: MetaListType[]) => void; // 设置回显数据
  reset: () => void; // 重置到上次设置的数据
}

代码示例

	const [table, setTable] = useState([]);
	const [value, setValue] = useState<MetaListType[]>([]);

	<MetaBase
		value={value}
		showFields={false}
		toolbar={[
      'filter',
      'summarize',
      'joinData',
      'permissionTable',
      'customColumn',
      'sort',
      'rowLimit',
    ]}
    getTables={async (id: string) => {
      let tables = [
        'YBT_PM_BHJQTDBXY',
      ];

      return tables.map((item) => {
        return {
          name: item,
          alias: item,
        };
      });
    }}
		getColumns={async (name: string) => {
			let data: MetaData_ColumnsType[] = [
        {
          database_type: 'STRING',
          name: 'C_RSV5',
          select: true,
          special_type: '',
          name_zh: '备用字段(项目组可使用)',
        },
			];
			return data;
		}}
		onOk={(v) => {
			console.log(v);
		}}
	/>