TypeScript SDKReferenceAPI

Query Builder API

Quick reference for the hypequery ClickHouse query builder API.

Use this page as a quick method index. For concepts and worked examples, use the main query-building guides.

Start Here

Core Methods

table()

db.table('users')

Starts a query from a typed table.

from()

const totals = db.table('orders')
  .select(['customer_id'])
  .sum('amount', 'total_amount');

db.from(totals).select(['customer_id', 'total_amount']);

Starts a query from another query builder. The nested query's output columns become the typed column scope of the outer query.

select()

db.table('users').select(['id', 'name', 'email'])

Chooses output columns and updates the inferred result type.

where()

db.table('users').where('status', 'eq', 'active')

Adds predicates with typed operators and values. See Where.

execute()

const rows = await db.table('users').select(['id']).execute();

Runs the query and returns typed results.

stream()

const stream = await db.table('events').stream();

Streams result batches for large datasets.

streamForEach()

await db.table('events').streamForEach(async (row) => {
  await processEvent(row);
});

Processes rows incrementally with a callback.

Join Methods

  • innerJoin()
  • leftJoin()
  • rightJoin()
  • fullJoin()

See Joins for patterns and examples.

Other Common Methods

  • groupBy()
  • having()
  • orderBy()
  • limit()
  • offset()
  • distinct()
  • prewhere()
  • final()
  • whereNull() / whereNotNull()
  • settings()
  • raw()
  • rawQuery()
  • withCTE()
  • withRecursiveCTE()
  • from()
  • toSQL()
  • toSQLWithParams()

Use the dedicated guides above for examples and edge cases.

On this page

Get early access to hypequery cloud.

Cloud hosts the same model you run in your backend, with a managed API and MCP server, versions, and rollback. We're letting teams in a few at a time. Join the waitlist and we'll reach out when your project can go live.

How do you want to build your analytics layer? (Optional)
What features do you most need? (Optional)

Pick as many as you like.

Only your email is required. All other questions are optional.