Contents
In brief
You have a TypeScript backend on TypeORM or Prisma and add ClickHouse for analytics. The first impulse is to point the ORM at it. The Dev.to answer is short: you cannot, and you should not want to. Neither TypeORM nor Prisma ships a ClickHouse driver; Prisma $queryRaw cannot reach it; Drizzle lacks a first-party dialect. Keep the ORM on transactional Postgres and add a ClickHouse-native analytics layer.
What happened
The article compares what actually works from TypeScript. Official @clickhouse/client is fast, dependency-light, supports parameterized queries, and has a web build for edge/browser. Downsides: result types are asserted by hand, and 64-bit integers/Decimals come back as strings in JSON.
hypequery is a typed query builder wrapping the official client (Apache-2.0): types from the live schema, compile-time errors for bad columns. The maintainer discloses the conflict of interest and still compares options fairly. It fits teams with many queries or a changing schema.
ClickHouse Cloud from TypeScript needs HTTPS on port 8443, longer timeouts for idle services, @clickhouse/client-web on edge, a read-only app user, and deliberate conversion of 64-bit numbers returned as strings.
Why it matters
An ORM models rows, relations, and transactional migrations. An analytical store thinks in columns, compression, and scans. Even if a driver appeared, “entities” would sit poorly on MergeTree and materialized views.
Two layers are not fashion duplication: the transactional path stays predictable; the analytical path stays fast. Gluing them with one Active Record usually ends in raw SQL and type surprises.
In practice
- Postgres + ORM for writes; ClickHouse + native client for reports and events.
- Start with
@clickhouse/client; move to a typed builder as query count and schema churn grow. - Convert Int64/Decimal from strings explicitly — do not blind
Number(...). - On Cloud, use a read-only app user and extra timeout after idle.
- On edge, take the web client, not the Node build.
Takeaway
ClickHouse from TypeScript is a separate contract, not “another Prisma datasource”. The official client covers the start; a typed layer pays off when analytical queries pile up.



Comments