@graffy/clickhouse

中文文档
0.19.7发布于 2026/09/16Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 6833

Graffy provider for ClickHouse.

原始使用文档

ClickHouse Provider

Graffy provider for ClickHouse.

Current scope is intentionally minimal and focused on tracker-like workloads:

  • ID reads and $key reads
  • Range args: $all, $first, $last, $order, $after, $before
  • Filter operators: $eq, $not, $lt, $lte, $gt, $gte, $re, $ire, $text, $cts, plus list shorthand (prop: [a, b])
  • $text performs case-insensitive substring search and is designed for a matching lowerUTF8(column) ngrambf_v1 index. For native Array(...) columns, $cts checks that every supplied value is present.
  • Dot-path filters on JSON-encoded string columns and native Map(...) columns (for example sources.messageId or recordIds.gmailMessageId)
  • Projection pushdown for ID and $key reads. Graffy selects only requested columns plus the ID, version, and ordering values needed for read metadata and pagination. Nested projections on JSON-encoded strings use JSONExtractRaw; native JSON projections read direct subcolumns. Both are rebuilt into the requested nested shape before decoding.
  • Join filters via subqueries (for example $key: { syncJob: { ... } })
  • Aggregates: $count, $sum, $avg, $max, $min, $card with $group: true and $group: [..]
  • Writes: single-row id writes with $put

The default table model is append-only MergeTree. Reads do not add FINAL unless you explicitly opt into final: true for a legacy ReplacingMergeTree table.

Write support is append-only. $put is mandatory, writes must target a scalar id path, and the adapter always does a blind insert. Filter writes, patch-style updates, and deletes are not supported.

The default idCol is id, and the default verCol is time.

idCol and verCol must be Graffy-compatible: when loaded through the ClickHouse client they should be strings or numbers. verCol should also be backed by a table DEFAULT expression. If a write provides a value for verCol, it is inserted as-is. If not, the column is omitted from the insert and ClickHouse supplies the default value.

E2E tests

ClickHouse e2e coverage lives in src/clickhouse/test/e2e.test.js.

  • Start server: npm run ch:up
  • Stop/clean server: npm run ch:clean
  • Run ClickHouse tests (unit + e2e): npm test -- src/clickhouse

版本与发布记录

@graffy/clickhouse 共发布 12 个版本,首次发布于 2026/03/27;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.19.7latest2026/09/162 个月前
0.19.62026/08/173 个月前
0.19.52026/08/033 个月前
0.19.42026/06/304 个月前
0.19.32026/05/215 个月前
0.19.1-alpha.3pre2026/05/166 个月前

关于 @graffy/clickhouse 的常见问题

@graffy/clickhouse 是什么?

Graffy provider for ClickHouse.

如何安装 @graffy/clickhouse?

在项目目录运行 npm install @graffy/clickhouse,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@clickhouse/client(^1.17.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@graffy/clickhouse 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@graffy/clickhouse 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@graffy/clickhouse 可以商用吗?

@graffy/clickhouse 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@graffy/clickhouse 的下载量有多少?

根据 npm 官方下载统计,@graffy/clickhouse 在 2026/10/17 – 2026/11/15 这 30 天内被下载 6,833 次,日均约 228 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@graffy/clickhouse 还在维护吗?

最新版本 0.19.7 发布于 2026/09/16(2 个月前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/03/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。