Reference
createClickHouseDB
The entry point that turns a @clickhouse/client instance into a typed database handle.
createClickHouseDB<DB>(options) is the entry point of the library. You give
it a TypeScript interface describing your schema and (usually) a configured
@clickhouse/client instance, and you get back a typed db handle.
import { createClient } from "@clickhouse/client";
import { createClickHouseDB } from "@oorestisime/quarry";
interface DB {
users: {
id: number;
email: string;
};
}
const db = createClickHouseDB<DB>({
client: createClient({ url: "http://localhost:8123" }),
});Options
The options object is rendered live from the source:
Prop
Type
What you get back
db is an instance of ClickHouseDB<DB>. The methods you actually use are:
db.selectFrom(...)— start aSELECTquerydb.insertInto(...)— start anINSERTquerydb.with(name, callback)— add a CTE that the rest of the chain can referencedb.table(name)— build an explicit table source (forFINAL, custom aliases, etc.)
See the guides for end-to-end examples of each.